天天看點

Matlab與C++接口與混合程式設計讨論小結

(轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: 小和尚

Posted on: 2002-10-18 10:01

本文主要讨論“用c編寫mex程式”以及“VC++中使用MATLAB的C++數學庫和MCC生成的程式”,最後對MIDEVA(Matcom)的使用方法作了介紹。

目 錄

第一章、概述

第二章、在Matlab中使用mex和mcc(作者dodoo,energy)

2.1 用c編寫mex程式[1]--dodoo

2.2 用c編寫mex程式[2]--dodoo

2.3 用c編寫mex程式[3]--dodoo

2.4 用c編寫mex程式[4]--dodoo

2.5 用c編寫mex程式[5]--dodoo

2.6 用c編寫mex程式[6]--dodoo

2.7 VC++中使用MATLAB的C++數學庫和MCC生成的程式--energy

第三章、Matcom的使用

3.1 概述

3.1.1 Matcom能作什麼

3.1.2 Matcom的工作原理

3.1.3 Matcom的不足

3.1.4 Matcom下載下傳位址及網絡資源

3.2 版本及安裝注意事項

3.2.1 MIDEVA 4.0 的安裝

3.2.2 MIDEVA 4.5 的安裝

3.3 用Matcom翻譯m檔案

3.4 如何得到CPP源檔案

3.5 在CB中C++與Matlab語言混編

3.6 程式的釋出

附錄一、Matcom的函數分類清單--

第一章、概述

Matlab是當今世界上使用最為廣泛的數學軟體,它具有相當強大的數值計算、資料處理、系統分析、圖形顯示,甚至符号運算功能,是一個完整的數學平台,在這個平台上,你隻需寥寥數語就可以完成十分複雜的功能,大大提高了工程分析計算的效率。另外由于Matlab的廣泛使用,于是出現了為各個領域專門使用的工具箱(即在某一研究領域常用數學工具的函數包),這些工具箱的出現更加促進了Matlab的流行。

Matlab強大的功能隻能在它所提供的平台上才能使用,也就是說,你必需在安裝有matlab系統的機器上使用.m檔案,這樣就給工程計算帶來了很大不便;特别是,在matlab中,使用的行解釋方式執行代碼,這樣大大地限制了代碼執行速度。于是人們想到,能否開發一個matlab與其他進階語言的接口,這樣就可以把matlab的強大功能融入各種應用程式中,并且通過進階語言編譯器編譯為2進制代碼, 進而大大提高了執行速度。

于是matlab的5.1版本提供了自帶的C++ Complier,同時MathTools公司也為Matlab開發了m檔案高效解釋和調試IDE:MIDEVA。經過近兩年的發展,matlab 5.3中的C complier--mcc版本已經為2.0,而MIDEVA最新版本為4.5。 将matlab與C混合程式設計大概有如下三種方法:

1.用Matlab的mcc将.m檔案翻譯為cpp源檔案,然後在C編譯器中調用也可以用mcc編譯編譯為stand-alone程式。

2.用Matcom(MIDEVA)将.m檔案翻譯為cpp代碼,并編譯為exe或dll 檔案。 

3.按照matcom的文法,在VC或BCB中直接書寫matlab語句(與matlab很相似),這也是我最喜歡用的方法。 

方法1和2/3各有利弊,1不支援圖形(支援圖形的庫國内現在還沒有D),1對類支援也不夠,2支援絕大多數的matlab語句(包括圖形),但對于struct等的支援也有缺陷。

--------------------------------------------------------------------------------

第二章、

第一節、用c編寫mex程式[開篇]

用C編寫mex程式

大家都知道,matlab是一種解釋型的程式設計環境,也就是說,跟以前的basic一樣,是讀一句執行一句的。這樣做可以很友善的實作程式設計過程中的互動,也免去了麻煩又耗時的編譯過程。但凡事有一利必有一弊,matlab在執行時速度慢也就根源于此。在matlab裡

tic

for i=1:10000

b(i)=a(10001-i);

end

怎麼樣,是不是很慢?

你的程式裡如果再多幾個這樣的循環,運作速度就可想而知了。

上面程式的功能是将向量a裡的資料逆序賦給向量b。下面的程式可以實作相同的功能

tic

b=a(10000:-1:1);

為什麼這個程式運作速度就這麼快呢?這是因為matlab裡的基礎矩陣運算函數,像轉置,複制等等,都是以二進制程式的形式存在的,運作起來速度當然比解釋執行10000次,是以編matlab程式時,應該盡量避免用循環語句,而使用等效的矩陣運算。雖然這樣但總是有的時候沒法找到對應的矩陣運算來等效,或編出來的程式複雜得讓人沒法修改。

簡單地說,mex程式就是根據一定的接口規範(mtlab提出的)編寫的一個dll,matlab 比如我編了一個mex函數,名字叫max2.dll,那麼隻要把這個dll所在的目錄加到matlab

的搜尋路徑裡(用addpath),就可以像調用普通matlab函數一樣來調用它了。因為把循環體放到了二進制程式中,執行速度快得多。

Mex檔案既可以用c,也可以用fortran來編。因為我用的是c語言,是以下面的介紹都是用c語言編寫mex檔案的方法。如果你用的是fortran,請你自己去看Apiguide.pdf,裡面有詳細說明。  

--------------------------------------------------------------------------------

第二章、

第二節、用c編寫mex程式[一]

前面說到通過把耗時長的函數用c語言實作,并編譯成mex函數可以加快執行速度。這Matlab5.1本身是不帶c語言的編譯器的,是以要求你的機器上已經安裝有VC,BC或Watcom C中的一種。如果你在安裝Matlab時已經設定過編譯器,那麼現在你應該就可以使用mex指令來編譯c語言的程式了。如果當時沒有選,隻要在Matlab裡鍵入 mex -setup,就會出現一個DOS方式視窗,下面隻要根據提示一步步設定就可以了。由于我用的是w聽說Matlab5.2已經内置了C語言的編譯器,那麼下面的這些可能就用不着了。可惜現需要注意的是,在設定編譯器路徑時,隻能使用路徑名稱的8字元形式。比如我用的V C5裝在路徑 C:\PROGRAM FILES\DEVSTUDIO下,那在設定路徑時就要寫成:C:\PROGRA~1 這樣設定完之後,mex就可以執行了。為了測試你的路徑設定正确與否,把下面的程式存為hello.c。

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

{

mexPrintf("hello,world!\n");

}

假設你把hello.c放在了C:\TEST\下,在Matlab裡用CD C:\TEST\ 将目前目錄改為C:\TEST\(注意,僅将C:\TEST\加入搜尋路徑是沒有用的)。現在敲:

mex hello.c

如果一切順利,編譯應該在出現編譯器提示資訊後正常退出。如果你已将C:\TEST\加入了搜尋路徑,現在鍵入hello,程式會在螢幕上打出一行:

hello,world!

看看C\TEST\目錄下,你會發現多了一個檔案:HELLO.DLL。

這樣,第一個mex函數就算完成了。怎麼樣,很簡單吧。下一次,會對這個最簡單的程式進行分析,并給它增加一些功能。  

--------------------------------------------------------------------------------

第二章、

第三節、用c編寫mex程式[三]

分析hello.c,可以看到程式的結構是十分簡單的,整個程式由一個接口子過程mexFunction構成。前面提到過,Matlab的mex函數有一定的接口規範,就是指這

nlhs:輸出參數數目

plhs:指向輸出參數的指針

nrhs:輸入參數數目

例如,使用 [a,b]=test(c,d,e) 調用mex函數test時,傳給test的這四個參數分别是2,plhs,3,prhs。其中:

prhs[0]=c

prhs[1]=d

prhs[2]=e

當函數傳回時,将會把你放在plhs[0],plhs[1]裡的位址賦給a和b,達到傳回資料的目的。

細心的你也許已經注意到,prhs和plhs都是指向類型mxArray類型資料的指針。

這個類型是在mex.h中定義的,事實上,在Matlab裡大多數資料都是以這種類型存在。當然還有其他的資料類型,可以參考Apiguide.pdf裡的介紹。

為了讓大家能更直覺地了解參數傳遞的過程,我們把hello.c改寫一下,使它能根據輸入參數的變化給出不同的螢幕輸出:

//hello.c 2.0

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

{

int i;

i=mxGetScalar(prhs[0]);

if(i==1)

mexPrintf("hello,world!\n");

else

mexPrintf("大家好!\n");

}

将這個程式編譯通過後,執行hello(1),螢幕上會打出:

hello,world!

而hello(0)将會得到:

大家好!

現在,程式hello已經可以根據輸入參數來給出相應的螢幕輸出。在這個程式裡,除了用到了螢幕輸出函數mexPrintf(用法跟c裡的printf函數幾乎完全一樣)外,還用到了一 個函數:mxGetScalar,調用方式如下: 

i=mxGetScalar(prhs[0]); 

"Scalar"就是标量的意思。在Matlab裡資料都是以數組的形式存在的,mxGetScalar的作用就是把通過prhs[0]傳遞進來的mxArray類型的指針指向的資料(标量)賦給C程式裡的變量。這個變量本來應該是double類型的,通過強制類型轉換賦給了整形變量i。

既然有标量,顯然還應該有矢量,否則矩陣就沒法傳了。看下面的程式:

//hello.c 2.1

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[],

int nrhs, const mxArray *prhs[])

{

int *i;

i=mxGetPr(prhs[0]);

if(i[0]==1)

mexPrintf("hello,world!\n");

else

mexPrintf("大家好!\n");

}

這樣,就通過mxGetPr函數從指向mxArray類型資料的prhs[0]獲得了指向double類型的指針。

但是,還有個問題,如果輸入的不是單個的資料,而是向量或矩陣,那該怎麼處理呢?通過mxGetPr隻能得到指向這個矩陣的指針,如果我們不知道這個矩陣的确切大小,就

沒法對它進行計算。 為了解決這個問題,Matlab提供了兩個函數mxGetM和mxGetN來獲得傳進來參數的行數和列數。下面例程的功能很簡單,就是獲得輸入的矩陣,把它在螢幕上顯示出來:

//show.c 1.0

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

{

double *data;

int M,N;

int i,j;

data=mxGetPr(prhs[0]); //獲得指向矩陣的指針

M=mxGetM(prhs[0]); //獲得矩陣的行數

N=mxGetN(prhs[0]); //獲得矩陣的列數

for(i=0;i

{

for(j=0;j

mexPrintf("%4.3f ",data[j*M+i]);

mexPrintf("\n");

}

}

編譯完成後,用下面的指令測試一下:

a=1:10;

b=[a;a+1];

show(a)

show(b)

需要注意的是,在Matlab裡,矩陣第一行是從1開始的,而在C語言中,第一行的序數為零,Matlab裡的矩陣元素b(i,j)在傳遞到C中的一維數組大data後對應于data[j*M+i] 。  

--------------------------------------------------------------------------------

第二章、

第四節、用c編寫mex程式[四]

輸入資料是在函數調用之前已經在Matlab裡申請了記憶體的,由于mex函數與Matlab共用同一個位址空間,因而在prhs[]裡傳遞指針就可以達到參數傳遞的目的。但是,輸出參數

卻需要在mex函數内申請到記憶體空間,才能将指針放在plhs[]中傳遞出去。由于傳回指針類型必須是mxArray,是以Matlab專門提供了一個函數:mxCreateDoubleMatrix來實作記憶體的申請,函數原型如下:

mxArray *mxCreateDoubleMatrix(int m, int n, mxComplexity ComplexFlag)

m:待申請矩陣的行數

n:待申請矩陣的列數

為矩陣申請記憶體後,得到的是mxArray類型的指針,就可以放在plhs[]裡傳遞回去了。但是對這個新矩陣的處理,卻要在函數内完成,這時就需要用到前面介紹的mxGetPr。使用

mxGetPr獲得指向這個矩陣中資料區的指針(double類型)後,就可以對這個矩陣進行各種操作和運算了。下面的程式是在上面的show.c的基礎上稍作改變得到的,功能是将輸

//reverse.c 1.0

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[],

int nrhs, const mxArray *prhs[])

{

double *inData;

double *outData;

int M,N;

int i,j;

inData=mxGetPr(prhs[0]);

M=mxGetM(prhs[0]);

N=mxGetN(prhs[0]);

plhs[0]=mxCreateDoubleMatrix(M,N,mxREAL);

outData=mxGetPr(plhs[0]);

for(i=0;i for(j=0;j outData[j*M+i]=inData[(N-1-j)*M+i];

}

當然,Matlab裡使用到的并不是隻有double類型這一種矩陣,還有字元串類型、稀疏矩陣、結構類型矩陣等等,并提供了相應的處理函數。本文用到編制mex程式中最經常遇到

的一些函數,其餘的詳細情況清參考Apiref.pdf。  

--------------------------------------------------------------------------------

第二章、

第五節、用c編寫mex程式[五]

通過前面兩部分的介紹,大家對參數的輸入和輸出方法應該有了基本的了解。具備了這些知識,就能夠滿足一般的程式設計需要了。但這些程式還有些小的缺陷,以前面介紹的re由于前面的例程中沒有對輸入、輸出參數的數目及類型進行檢查,導緻程式的容錯性很#include "mex.h" 

void mexFunction(int nlhs, mxArray *plhs[],

int nrhs, const mxArray *prhs[])

{

double *inData;

double *outData;

int M,N;

//異常處理

if(nrhs!=1)

mexErrMsgTxt("USAGE: b=reverse(a)\n");

if(!mxIsDouble(prhs[0]))

mexErrMsgTxt("the Input Matrix must be double!\n");

inData=mxGetPr(prhs[0]);

M=mxGetM(prhs[0]);

N=mxGetN(prhs[0]);

plhs[0]=mxCreateDoubleMatrix(M,N,mxREAL);

outData=mxGetPr(plhs[0]);

for(i=0;i

for(j=0;j

outData[j*M+i]=inData[(N-1-j)*M+i];

}

在上面的異常進行中,使用了兩個新的函數:mexErrMsgTxt和mxIsDouble。MexErrMsgTxt在給出出錯提示的同時退出目前程式的運作。MxIsDouble則用于判斷mxArray中的資料是否double類型。當然Matlab還提供了許多用于判斷其他資料類型的函數,這裡不加詳述。

需要說明的是,Matlab提供的API中,函數字首有mex-和mx-兩種。帶mx-字首的大多是對mxArray資料進行操作的函數,如mxIsDouble,mxCreateDoubleMatrix等等。而帶mx字首的則大多是與Matlab環境進行互動的函數,如mexPrintf,mxErrMsgTxt等等。了解了這一點,對在Apiref.pdf中查找所需的函數很有幫助。

至此為止,使用C編寫mex函數的基本過程已經介紹完了。下面會在介紹幾個非常有用的函數調用。如果有足夠的時間,也許還會有一個更複雜一些的例程。

--------------------------------------------------------------------------------

第二章、

第六節、用c編寫mex程式[六]

我們之是以使用Matlab,很重要的考慮是Matlab提供了相當豐富的矩陣運算函數和各種toolbox。在編制mex函數時,有時我們也會遇到一些操作,在Matlab下,隻需要一個

為了在mex函數裡調用Matlab指令,我們就需要用到一個函數mexCallMATLAB,原型如下:

int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *command_name);

有了前面的基礎,使用這個函數就顯得十分容易了。下面給出一個例程,功能是将輸入

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

{

double *inData;

mxArray *IN[1];

mxArray *OUT[1];

double *outData;

int M,N;

int i,j;

//異常處理

if(nrhs!=1)

mexErrMsgTxt("USAGE: b=rot(a)\n");

if(!mxIsDouble(prhs[0]))

mexErrMsgTxt("the Input Matrix must be double!\n");

//計算轉置

if(mexCallMATLAB(1,OUT,1,prhs,"'")) 

mexErrMsgTxt("Error when compute!\n"); 

//根據輸入參數數目決定是否顯示 if(nlhs==0) 

mexCallMATLAB(0,IN,1,OUT,"disp");

else

plhs[0]=OUT[0];

}

關于這個例子,相信大家一看就明白,我就不多說了。  

--------------------------------------------------------------------------------

第三章、Matcom的使用

3.1 概述

3.1.1 Matcom能作什麼

Matcom是一個十分有用的.m檔案翻譯器(Replacement),它的主要優點我認為有以下幾點:

1>它提供了matlab中.m檔案與其他進階語言的接口,使.m檔案可以編譯為脫離matlab環境獨立執行的可執行性程式,這樣

。提高了代碼的複用率

。提高了代碼的執行速度

。使純文字的.m檔案變為二進制的可執行程式,增加了知識保護的安全性2>它提供了近千個數學函數,對于其他進階語言編譯器來說,提供了一個豐富的數學庫,基本上在matlab上能用的常用函數都可以在進階語言中直接調用。

數學函數主要包括:

。矩陣屬性函數

。矩陣生成函數

。矩陣操作函數

。矩陣變換函數

。數學函數

。特殊函數

。數值函數

。串函數

。繪圖函數

。顔色函數

。函數函數

。存盤及讀檔案

。系統資源函數

。系統操作函數

。判斷函數(Is函數族)

。付氏變換

等等,可參見本文附錄

3>提供了.m檔案的友善快捷的編譯調适環境,可以step, watch,breakpoint等各種調試手段。

3.1.2 Matcom的工作原理

Matcom的矩陣運算部分是基于一個名為Matrix的C++數學庫,這個庫提供了絕大多數的關于矩陣類、矩陣操作函數、數值計算函數、數學函數等的定義,在Matcom中是以lib目錄下的*.lib以及windows/system/對應名稱的dll檔案提供的。

Matcom的另一大部分就是圖形部分,它是用一種非常流行的繪圖OCX控件Teechart來實作的,這種控件對于一般的繪圖功能都可以實作,但也存在一定缺陷。在Matcom4.5版本中使用的是TeeChart3.0。繪圖函數功能主要在lib檔案和window/system/ago*.dll中定義的。

Matcom編譯.m檔案是先将.m檔案按照與matcom的Cpp庫的對應關系,翻譯為CPP源代碼,然後用對應版本的C編譯器将該CPP檔案編譯為exe或dll檔案,是以,在第一次運作時讓指定C Complier的路徑是必需的,否則将無法編譯。指定好的C Complier的資訊寫在Matcom/bin/matcom.ini檔案中。

3.1.3 Matcom的不足

Matcom并不是全能的,對于大多數Matlab函數都可以進行CPP實作,但有些由于其功能有限,隻能期待以後的版本來不斷補充了。 總的來說,matcom有以下缺欠:

1.對class資料類型部分支援

2.eval,feval,clear等語句不能在C中實作(如果實作的話,一個文本編輯器就可以成為一個matlab了:))

3.圖形視窗有些不僅如人意,如fill3,hide等語句無法實作,surf等語句也無法畫出象matlab中哪樣精細的圖像來,特别是色彩比較難看:( 等等

3.1.4 Matcom下載下傳位址及網絡資源

下載下傳位址是版上詢問最多的問題,再次建議大家能到教育網的搜尋引擎

http://pccms.pku.edu.cn:8000/

http://search.igd.edu.cn

http://soft.cs.uestc.edu.cn/search.php

搜尋關鍵字matcom或MIDEVA,可以查找教育網上的最新的matcom資源Matcom的開發者Mathtools公司位址是http://www.mathtools.com/上面也提供了免費下載下傳服務他們還會給你一個evaluation key),如果你從哪裡下載下傳,他們會給你定期發email告訴最新的動态。 大家可以定期到公司首頁看看有沒有版本更新  

--------------------------------------------------------------------------------

3.2 版本及安裝注意事項

3.2.1 Matcom 4.0 的安裝

由于matcom4.0所代的dll檔案相對較小,是以便于釋出小型程式,是以這裡也對它作一定讨論。

matcom4.0在第一次使用時需要你輸入密碼,否則無法運作,不過網上已經有matcom4 的注冊機,可以查找一個叫regmat4.exe的小程式,輸入你想使用的時間區間,然後就會産生一個合法密碼,輸入這個密碼後,mideva在window目錄建立一個名字叫mt_eva l.txt的 文本檔案,裡面就儲存了你輸入的密碼,不過你也可以在執行matcom之前直接建立這個 檔案, 在裡面寫1/1/1999-1/1/2010-64562264就可使用到2010年。

通過了密碼後,它還有一些限制,如繪圖時間不超過60分鐘限制,繪圖時出現版權對話 框 等,不過這些已經被energy等諸位大蝦給破解了具體如下

energy:

使用PLOT功能時會出現一個對話框,可以這樣去掉:

C:\Windows\system\ago.dll

FIND: 83 C4 08 85 C0 75 05

REP : -- -- -- -- -- EB --

如果還想去掉figure标題欄上的[Evaluation software]:

FIND: 43 61 70 74 75 72 65 00 20 5B

REP : -- -- -- -- -- -- -- -- -- 00

huangfh (hoho)對60分鐘時間的破解, 就比較完整了:

FIND : 2B D1 81 FA 10 0E 00 00 7E 10

REP : -- -- -- -- -- -- -- -- EB --

3.2.2 Matcom 4.5 的安裝

感謝energy的破解,Matcom4.5的密碼為FREE-4.5-1193046-80295111

matcom4.5在安裝時需要你輸入密碼,mideva在window的系統資料庫中HKEY_CURRENT_USER\Software\MathTools\Matcom.50\License\

下面添加一個鍵,鍵名預設,鍵值為FREE-4.5-1193046-80295111

你如果删除它,再次啟動matcom的時候,就會再次詢問密碼。不過好在如果通過這個密碼之後,程式釋出時就不再有限制了,也就是在這個注冊後的系統中編譯的程式,釋出時就不用代一個注冊檔案了  

--------------------------------------------------------------------------------

3.3 用Matcom翻譯m檔案

直接調适M檔案:在主界面上打開.m檔案的主檔案,在菜單中選擇compile to exe or dll 就可以了,你也可以設定斷點後,就可以檢視變量的值,這些将在主視窗的一側出現,輕按兩下就可得到其目前值。編譯後的cpp、exe、dll檔案都在matcom 目前工作目錄下,如果是debug模式,就在 dubug目錄下找,否則就在Release目錄下找。

3.4 在CB中C++與Matlab語言混編

這種方法是我最喜歡的方法,因為這樣不但可以發揮matcom強大的數學計算功能,還可以結合可視化編譯環境來進行界面開發,可以制作完整的應用計算軟體,傳遞使用者使用。 我所用的可視IDE是Inprise公司的C++Builder 3.0/4.0,matcom版本為4.0/4.5,注意,在CB4.0上隻能使用matcom4.5版本。

在進行程式設計之前你需要作如下準備工作

1.選擇菜單New\Console Wizard\Console Exe,建立一個Win32位DOS程式

2.将matcom\lib\matlib.h拷貝到CB\include目錄下

将matcom\lib\v4500b.lib拷貝到CB\lib目錄下

3.選擇菜單Project\Add to project\選擇lib\v4500.lib

于是程式變為

#pragma hdrstop

#include

#include "stdio.h"

#include "matlib.h"

//---------------------------------------------------------------------------

USELIB("v4500b.lib");

//---------------------------------------------------------------------------

#pragma argsused

int main(int argc, char **argv)

{

// Please Write Your Code Here */

return 0;

}

3.選擇菜單Project\Add to Reportaries\ 将該工程存為Project中的一個模闆。

OK,現在可以進行你所需要的工作了。

用菜單你存為的模闆建立一個新的工程,在代碼段寫

dMm(a); //define a Matrix class

a=zeros(3); //Let the matrix be a 3*3 zero matrix

disp(a); //Display the matrix

運作一下看看,程式會列印出3*3的0零陣稍微複雜一點的程式

dMm(a);dMm(b);dMm(c); //聲明三個矩陣

a=rand(3,2); //生成3*2随機陣

b=zeros(3,2);

c=a+b; //矩陣相加

c(1,c_p)=a(2,c_p); //matlab中寫為c(1,:)=a(2,:)

c=ctranspose(c); //矩陣轉置

disp(c);printf("\n");

disp(a);printf("\n");

getch();

c(colon(1,1,3))=a(colon(1,2,5)); //matlab中寫為c([1:1:3])=a([1:2:5])

disp(c);

getch();

可以發現在matlab中常用的一些表示都可以在matcom中找到對應,并且同樣友善有效。

再舉一個繪圖的例子,就用matcom自己帶的例子吧

subplot(121.0); //subplot(1,2,1)

surf((CL(peaks(25.0)))); //surf(peaks(25))

subplot(122.0); //subplot(1,2,2)

pcolor((CL(peaks(25.0)))); //pcolor(peaks(25))

colormap(TM("copper")); //colormap('copper')

drawnow() //必須有這句,否則隻畫一個圖出來

//這是我問他們的技術支援搞到的

可以看到基本上是一句對一句,沒有什麼多餘的話。是以習慣編寫matlab程式的同志寫matcom C的語句來也應該沒有什麼問題。 (但上面這個程式确實有問題,在mideva中編譯後第二個subplot 是可以正常畫出來的,但在CB中編譯就隻畫一個subplot樂,具體原因希望大家讨論,我現在也在試),mideva編譯該語句的指令是

bcc32 檔案名 -IC:\MATCOM45\lib -H=matlib.csm -v -a4 -5 -e

EXEFLAGS= -WC

DLLFLAGS= -WD

我想CB中可能要改option,大家試試看。

總的說來,決大多數的matlab的語句都可以輕松移植到CB中來,是以就可以直接在 CB中寫matlab程式了,隻是大家要注意幾個關鍵的函數

colon(xstart,xstep,xstop) == xstart:xstep:xstop

(CL(A1),A2,A3....) == (A1,A2,A3,...)一個矩陣行,大多數

多參數輸入函數都用到CL

(BR(a1),a2,a3....) == (a1,a2,a3...)

TM("a string") == 'a string' TM将char *變為串矩陣

c_p == : 整行或整列

i_o == [out]=fun(in)就寫為fun(in, i_o, out)

其他的大家編幾個程式就清楚了。  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結(一) Copy to clipboard

Posted by: 小和尚

Posted on: 2002-10-18 10:07

3.6 程式的釋出

matcom可以用C編譯器把.m檔案編譯為為stand_alone的程式,是以,基本上不需要matlab系統,但一些必要的dll檔案還是需要的,這些dll在window\system\

下面,(在4.5版本中)大概有ago4500.dll,v4500v.dll,opengl32.dll, glu32.dll等 四個檔案

如果用的是4.0版本,釋出時要把ago.dll,mlib4...dll(計不清楚了),opengl32.dll和glu32.dll打到安裝盤中,大概3M,然後在window目錄安裝一個名字叫mt_eval.txt的

文本檔案,裡面寫1/1/1999-1/1/2010-64562264即可

附錄:Matcom C數學庫函數清單(部分)

這是一個豐富的數學庫,約600個函數,包括sim()函數

--------------------------------------------------------------------------

矩陣基礎類

系統常數

特殊函數

異常處理函數

矩陣生成函數

作業系統資源函數

數值計算函數

數學函數

矩陣操作函數

矩陣屬性函數

圖形函數

顔色函數

使用者介面函數

is*函數族

mex函數

字元串函數

類型轉換函數

**************************************************************************

>>> 矩陣基礎類

**************************************************************************

class Mm

{

DLLI Mm();

DLLI Mm(int isc, int iss, int nonzeros, int nrows, int ncols, mt_matrix_ty

pes new_type=mt_double_matrix);

DLLI Mm(int isc, int iss, int nonzeros, int new_ndims, const int new_dims[

max_ndims], mt_matrix_types new_type=mt_double_matrix);

DLLI Mm(i_o_t, const char* mname, int isglobal);

DLLI Mm(const char* mname, int m, int n);

DLLI Mm(int aisc, cMm x, cMm y, cMm dim1, op_t op, int do_dim, Mm& minmax_

idx);

DLLI Mm(m_type src);

DLLI Mm(cMm src);

DLLI Mm(cMm src, const char* mname);

DLLI Mm(const Mc[$ src)]

DLLI Mm(cMr src, int err=1);

DLLI ~Mm();

Mm RDLLI operator =(cMm src);

void DLLI deepcopy(cMm src, mt_matrix_types new_type=mt_uninit_matrix);

void DLLI deepcopy(int isc, cMm src, mt_matrix_types new_type=mt_uninit_ma

trix);

void DLLI deepcopy(int isc, int iss, cMm src, mt_matrix_types new_type=mt_

uninit_matrix);

int DLLI getreal(int force=0) const;

int DLLI getcomplex();

void DLLI collapse();

inline int DLLI rows() const { return dims[0]; }

inline int DLLI cols() const { return dims[1]; }

int DLLI size() const;

int DLLI size(int dim) const;

int DLLI nsingleton() const;

int DLLI vectordim() const;

int DLLI length() const;

const char PDLLI getname() const { return self_name; }

void DLLI setname(const char* new_name);

int DLLI isstr() const { return (flags.str!=0); }

void DLLI setstr(int newd);

inline int DLLI issparse() const { return (flags.sparse!=0); }

void DLLI setsparse(int sp);

inline int DLLI islogical() const { return (flags.logical!=0); }

void DLLI setlogical(int newd);

inline int DLLI isglobal() const { return (flags.global!=0); }

inline int DLLI isstruct() const { return (fields!=NULL); }

inline int RDLLI getndims() const { return (int[$)ndims] }

inline int PDLLI getdims() const { return (int*)dims; }

inline M_types RDLLI getflags() { return flags; }

inline mt_matrix_types DLLI gettype() const { return flags.type; }

inline int DLLI getnfields() const { return nfields; }

inline const char PPDLLI getfields() const { return fields; }

inline int DLLI isc() const { return (pi!=NULL); }

int DLLI issamename(const char *s) const { return s==self_name; }

int DLLI dirty() const;

int DLLI getp() const { return p; }

Mm DLLI safebr(int i0) const;

inline m_type PDLLI getpr(m_type*) const { return (m_type*)pr; }

inline m_type PDLLI getpi(m_type*) const { return (m_type*)pi; }

inline uint8 PDLLI getpr(uint8*) const { return (uint8*)pr; }

inline uint8 PDLLI getpi(uint8*) const { return (uint8*)pi; }

inline Mm PDLLI getpr(Mm*) const { return (Mm*)pr; }

inline Mm PDLLI getpi(Mm*) const { return (Mm*)pi; }

inline m_type PDLLI getpr(m_type*,int i0) const { return i0-1+(m_type*)pr;

}

inline m_type PDLLI getpi(m_type*,int i0) const { return i0-1+(m_type*)pi;

}

inline uint8 PDLLI getpr(uint8*,int i0) const { return i0-1+(uint8*)pr;

}

inline uint8 PDLLI getpi(uint8*,int i0) const { return i0-1+(uint8*)pi;

}

inline Mm PDLLI getpr(Mm*,int i0) const { return i0-1+(Mm*)pr; }

inline Mm PDLLI getpi(Mm*,int i0) const { return i0-1+(Mm*)pi; }

inline m_type PDLLI getpr(m_type*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(m_type*)pr; }

inline m_type PDLLI getpi(m_type*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(m_type*)pi; }

inline uint8 PDLLI getpr(uint8*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(uint8*)pr; }

inline uint8 PDLLI getpi(uint8*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(uint8*)pi; }

inline Mm PDLLI getpr(Mm*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(Mm*)pr; }

inline Mm PDLLI getpi(Mm*,int i0,int i1) const { return i0-1+(i1-1

)*dims[0]+(Mm*)pi; }

m_type PDLLI addr() const;

m_type PDLLI addr(int i0) const;

m_type PDLLI addr(int i0,int i1) const;

m_type PDLLI addi() const;

m_type PDLLI addi(int i0) const;

m_type PDLLI addi(int i0,int i1) const;

inline int PDLLI getindex() const { return index; }

inline int RDLLI getnnz() const { return (int[$)nnz] }

m_type RDLLI r() const;

m_type RDLLI r(double i0) const;

m_type RDLLI r(double i0, double i1) const;

m_type RDLLI r(double i0, double i1, double i2) const;

m_type RDLLI i() const;

m_type RDLLI i(double i0) const;

m_type RDLLI i(double i0, double i1) const;

m_type RDLLI i(double i0, double i1, double i2) const;

uint8 RDLLI ur(int i0) const;

uint8 RDLLI ur(int i0, int i1) const;

Mm RDLLI mr(int i0) const;

Mm RDLLI mr(int i0, int i1) const;

Mr DLLI member(const char* field) const { return Mr(*this, field); }

Mr DLLI operator ()(cMm i0) const { return Mr(Mr_idx_paren, *this, i0); }

Mr DLLI operator ()(cMm i0, cMm i1) const { return Mr(Mr_idx_paren, *this,

i0, i1); }

Mr DLLI operator ()(cMm i0, cMm i1, cMm i2) const { return Mr(Mr_idx_paren

, *this, i0, i1, i2); }

Mr DLLI operator ()(cMm i0, cMm i1, cMm i2, cMm i3) const { return Mr(Mr_i

dx_paren, *this, i0, i1, i2, i3); }

Mr DLLI br(cMm i0) const { return Mr(Mr_idx_br,*this, i0); }

Mr DLLI br(cMm i0, cMm i1) const { return Mr(Mr_idx_br,*this, i0, i1); }

Mr DLLI br(cMm i0, cMm i1, cMm i2) const { return Mr(Mr_idx_br,*this, i0,

i1, i2); }

Mr DLLI br(cMm i0, cMm i1, cMm i2, cMm i3) const { return Mr(Mr_idx_br,*th

is, i0, i1, i2, i3); }

m_type[$ fastindex(double i0) const { return pr[int(i0)-1]] }

m_type& fastindex(double i0, double i1) const { return pr[int(i0)-1+(int(i

1)-1)*dims[0]]; }

void DLLI vwcopy1(cMm src, cMm v);

void DLLI vwcopy2(cMm src, cMm v, cMm w);

void DLLI vwcopyn(cMr src, cMm rhs);

void DLLI vwcopy0(cMr src);

int DLLI findfield(const char* field, int err) const;

const char PDLLI getfield(int i) const;

int DLLI addfield(const char* field,int quick);

int DLLI rmfield(const char* field);

void DLLI extend_nfields(int new_nfields);

int DLLI getclassid() const { return classid; }

void DLLI setclassid(int new_classid) { classid=new_classid; }

void DLLI reshape(const int m, const int n);

void DLLI reshape(const int new_ndims, const int new_dims[max_ndims]);

void DLLI print(int full) const;

void DLLI warn_uninit() const;

void DLLI resparse();

int DLLI search(int idx) const;

void DLLI sort();

void DLLI extend_nnz(int new_nnz);

}; // M

Mc DLLI BR(cMm src);

Mc DLLI CL(cMm src);

m_type DLLI scalar(m_type x);

m_type DLLI scalar(cMm x);

Mm DLLI switchinit(cMm x);

********************************************************************** 

>>> 系統常數

********************************************************************** 

extern DLLW double DLLI nargin_val;

extern DLLW double DLLI nargout_val;

extern DLLW int DLLI nargin_set;

extern DLLW int DLLI nargout_set;

extern DLLW Mm DLLI TICTOC;

extern DLLW Mm DLLI ans;

extern DLLW Mm DLLI i;

extern DLLW Mm DLLI j;

extern DLLW Mm DLLI pi;

extern DLLW Mm DLLI Inf;

extern DLLW Mm DLLI NaN;

extern DLLW Mm DLLI eps;

extern DLLW Mm DLLI x_M;

extern DLLW Mm DLLI semi;

extern DLLW Mm DLLI c_p;

extern DLLW Mm DLLI nop_M;

extern DLLW Mm DLLI zero_M;

extern DLLW Mm DLLI one_M;

extern DLLW Mm DLLI l_M;

extern DLLW Mm DLLI page_screen_output;

extern DLLW Mm DLLI implicit_str_to_num_ok;

extern DLLW Mm DLLI empty_list_elements_ok;

extern DLLW Mm DLLI switchvar;

**********************************************************************

>>> 特殊函數

**********************************************************************

Mm DLLI airy(cMm z);

Mm DLLI airy(cMm k, cMm z);

Mm DLLI airy(cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI airy(cMm k, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI bessel(cMm nu);

Mm DLLI bessel(cMm nu, cMm z);

Mm DLLI bessel(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI bessela(cMm nu);

Mm DLLI bessela(cMm nu, cMm z);

Mm DLLI bessela(cMm nu, cMm z, i_o_t, Mm[$ J, Mm& ndigits)]

Mm DLLI besselh(cMm nu);

Mm DLLI besselh(cMm nu, cMm z);

Mm DLLI besselh(cMm nu, cMm k, cMm z);

Mm DLLI besselh(cMm nu, cMm k, cMm z, cMm scale1);

Mm DLLI besselh(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselh(cMm nu, cMm k, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselh(cMm nu, cMm k, cMm z, cMm scale1, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besseli(cMm nu);

Mm DLLI besseli(cMm nu, cMm z);

Mm DLLI besseli(cMm nu, cMm z, cMm scale1);

Mm DLLI besseli(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besseli(cMm nu, cMm z, cMm scale1, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselj(cMm nu);

Mm DLLI besselj(cMm nu, cMm z);

Mm DLLI besselj(cMm nu, cMm z, cMm scale1);

Mm DLLI besselj(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselj(cMm nu, cMm z, cMm scale1, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselk(cMm nu);

Mm DLLI besselk(cMm nu, cMm z);

Mm DLLI besselk(cMm nu, cMm z, cMm scale1);

Mm DLLI besselk(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI besselk(cMm nu, cMm z, cMm scale1, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI bessely(cMm nu);

Mm DLLI bessely(cMm nu, cMm z);

Mm DLLI bessely(cMm nu, cMm z, cMm scale1);

Mm DLLI bessely(cMm nu, cMm z, i_o_t, Mm[$ w, Mm& err)]

Mm DLLI bessely(cMm nu, cMm z, cMm scale1, i_o_t, Mm[$ w, Mm& err)]

**********************************************************************

>>> 特殊資料類型定義

***********************************************************************

Mm DLLI cell(cMm x);

Mm DLLI cell(cMm x, cMm y);

Mm DLLI cell(cMm x, cMm y, cMm o);

Mm DLLI cell(cMm x, cMm y, cMm o, cMm p);

Mm DLLI cells(cMm x);

Mm DLLI cells(cMm x, cMm y);

Mm DLLI cellstr(cMm x);

Mm DLLI cell_from_array(int n, const Mm* x[]);

Mm DLLI cell2struct(cMm x);

Mm DLLI cell2struct(cMm x, cMm f);

Mm DLLI cell2struct(cMm x, cMm f, cMm dim1);

int DLLI iscellstr(cMm x);

int DLLI isa(cMm x);

int DLLI isa(cMm x, cMm cls);

Mm DLLI mclass(cMm x);

Mm DLLI mclass(cMm x, cMm class_name);

Mm DLLI mchar(cMm varargin);

Mm DLLI mdouble(cMm x);

Mm DLLI mlogical(cMm x);

Mm DLLI muint8(cMm x);

Mm DLLI muint16(cMm x);

Mm DLLI fieldnames(cMm s);

Mm DLLI isfield(cMm s);

Mm DLLI isfield(cMm s, cMm f);

Mm DLLI getfield(cMm s);

Mm DLLI getfield(cMm s, cMm varargin);

Mm DLLI mstruct(cMm varargin);

Mm DLLI setfield(cMm s);

Mm DLLI setfield(cMm s, cMm field);

Mm DLLI setfield(cMm s, cMm field, cMm v);

Mm DLLI struct2cell(cMm s);

Mm DLLI rmfield(cMm s);

Mm DLLI rmfield(cMm s, cMm fields);

**********************************************************************

>>> 異常處理函數

**********************************************************************

***************************************************************************

********

>>> 矩陣生成函數

**********************************************************************

Mm DLLI cauchy(Mm x);

Mm DLLX cauchy(Mm x, Mm y);

Mm DLLI compan(cMm x);

Mm DLLI gallery(Mm n);

Mm DLLI hadamard(Mm n);

Mm DLLI hankel(Mm c);

Mm DLLI hankel(Mm c, Mm r);

Mm DLLI hilb(Mm n);

Mm DLLI invhilb(Mm n);

Mm DLLI magic(Mm n);

Mm DLLI pascalM(cMm n);

Mm DLLI pascalM(Mm n, Mm r);

Mm DLLI rosser();

Mm DLLI toeplitz(Mm c);

Mm DLLI toeplitz(Mm c, Mm r);

Mm DLLI vander(Mm x);

Mm DLLI wilkinson(cMm n);

**********************************************************************

>>> 作業系統資源函數

**********************************************************************

Mm DLLI cd();

Mm DLLI cd(cMm dir1);

Mm DLLI chdir(cMm dir1);

Mm DLLI copyfile(cMm src);

Mm DLLI copyfile(cMm src, cMm dest);

Mm DLLI deleteM(cMm filename);

Mm DLLI dos(cMm command);

Mm DLLI dos(cMm command, i_o_t, Mm[$ status, Mm& sout)]

Mm DLLI dos(cMm command, cMm echo);

Mm DLLI dos(cMm command, cMm echo, i_o_t, Mm[$ status, Mm& sout)]

Mm DLLI fclose(cMm fid);

Mm DLLI feof(cMm fid);

Mm DLLI ferror(cMm fid);

Mm DLLI ferror(cMm fid, cMm clear);

Mm DLLI ferror(cMm fid, cMm clear, i_o_t, Mm[$ msg, Mm& errnum)]

Mm DLLI ferror(cMm fid, i_o_t, Mm[$ msg, Mm& errnum)]

Mm DLLI fflush(cMm fid);

Mm DLLI fgetl(cMm fid);

Mm DLLI fgets(cMm fid);

Mm DLLI fgets(cMm fid, cMm nchar);

Mm DLLI filesep();

Mm DLLI fopen(cMm filename);

Mm DLLI fopen(cMm filename, cMm permission);

Mm DLLI fopen(cMm filename, cMm permission, cMm machine);

Mm DLLI fopen(cMm filename, cMm permission, cMm machine, i_o_t, Mm& fid, Mm&

msg);

Mm DLLI fopen(cMm filename, cMm permission, i_o_t, Mm[$ fid, Mm& msg)]

Mm DLLI fopen(cMm filename, i_o_t, Mm[$ fid, Mm& msg)]

Mm DLLI fopen(cMm fid, i_o_t, Mm[$ filename, Mm& permission, Mm& machine)]

Mm DLLI fprintf(cMm fid, cMm format1);

Mm DLLI fprintf(cMm fid, cMm format1, cMm varargin);

Mm DLLI fprintf(cMm x);

Mm DLLI fread(cMm fid);

Mm DLLI fread(cMm fid, cMm size);

Mm DLLI fread(cMm fid, cMm size, cMm precision);

Mm DLLI fread(cMm fid, cMm size, cMm precision, cMm skip);

Mm DLLI fread(cMm fid, cMm size, cMm precision, cMm skip, cMm machine);

Mm DLLI fread(cMm fid, cMm size, cMm precision, cMm skip, cMm machine, i_o_t

, Mm[$ A, Mm& count)]

Mm DLLI fread(cMm fid, cMm size, cMm precision, cMm skip, i_o_t, Mm& A, Mm&

count);

Mm DLLI fread(cMm fid, cMm size, cMm precision, i_o_t, Mm[$ A, Mm& count)]

Mm DLLI fread(cMm fid, cMm size, i_o_t, Mm[$ A, Mm& count)]

Mm DLLI fread(cMm fid, i_o_t, Mm[$ A, Mm& count)]

Mm DLLI frewind(cMm fid);

Mm DLLI fscanf(cMm fid);

Mm DLLI fscanf(cMm fid, cMm format1);

Mm DLLI fscanf(cMm fid, cMm format1, cMm size);

Mm DLLI fscanf(cMm fid, cMm format1, cMm size, i_o_t, Mm[$ A, Mm& count)]

Mm DLLI fscanf(cMm fid, cMm format1, cMm size, i_o_t, Mm& A, Mm& count, Mm&

errmsg);

Mm DLLI fscanf(cMm fid, cMm format1, i_o_t, Mm[$ A, Mm& count)]

Mm DLLI fseek(cMm fid);

Mm DLLI fseek(cMm fid, cMm offset);

Mm DLLI fseek(cMm fid, cMm offset, cMm origin);

Mm DLLI ftell(cMm fid);

Mm DLLI fullfile(cMm varargin);

Mm DLLI fwrite(cMm fid);

Mm DLLI fwrite(cMm fid, cMm A);

Mm DLLI fwrite(cMm fid, cMm A, cMm precision);

Mm DLLI fwrite(cMm fid, cMm A, cMm precision, cMm skip);

Mm DLLI fwrite(cMm fid, Mm A, cMm precision, cMm skip, cMm machine);

Mm DLLI help(cMm keyword);

Mm DLLI mkdir(cMm dir1);

Mm DLLI pathsep();

Mm DLLI printf(cMm format1);

Mm DLLI printf(cMm format1, cMm varargin);

Mm DLLI rmdir(cMm dir1);

Mm DLLI stderrM();

Mm DLLI stdinM();

Mm DLLI stdoutM();

Mm DLLI system(cMm cmd);

Mm DLLI type(cMm fname); 

Mm DLLI unixM(cMm command); 

Mm DLLI unixM(cMm command, i_o_t, Mm[$ status, Mm& sout)]

**********************************************************************

>>> 數值計算函數

**********************************************************************

Mm DLLI fft(cMm x);

Mm DLLI fft(cMm x, cMm n);

Mm DLLI fft(cMm x, cMm n, cMm dim1);

Mm DLLI ifft(cMm x);

Mm DLLI ifft(cMm x, cMm n);

Mm DLLI ifft(cMm x, cMm n, cMm dim1);

Mm DLLI dft(cMm x);

Mm DLLI fft2(cMm x);

Mm DLLI fft2(cMm x, cMm m);

Mm DLLI fft2(cMm x, cMm m, cMm n);

Mm DLLI ifft2(cMm x);

Mm DLLI ifft2(cMm x, cMm m);

Mm DLLI ifft2(cMm x, cMm m, cMm n);

Mm DLLI fftshift(cMm x);

Mm DLLI ifftshift(cMm x);

int DLLI automesh(cMm x);

int DLLI automesh(cMm x, cMm y);

int DLLI automesh(cMm x, cMm y, cMm z);

Mm DLLI dsearch(cMm x, cMm y, cMm tri, cMm xi, cMm yi);

Mm DLLI delaunay(cMm x);

Mm DLLI delaunay(cMm x, cMm y);

Mm DLLI delaunay(cMm x, cMm y, cMm sorted);

Mm DLLI griddata(cMm x, cMm y, cMm z, cMm xi, cMm yi);

Mm DLLI griddata(cMm x, cMm y, cMm z, cMm xi, cMm yi, cMm method);

Mm DLLI griddata(cMm x, cMm y, cMm z, cMm xi, cMm yi, i_o_t, Mm& XI, Mm& YI, Mm[$ ZI)]

Mm DLLI griddata(Mm x, Mm y, Mm z, Mm xi, Mm yi, cMm method, i_o_t, Mm& XI, Mm[$ YI, Mm& ZI)]

Mm DLLI interp1(cMm y);

Mm DLLI interp1(cMm y, cMm xi);

Mm DLLI interp1(Mm x, Mm y, Mm xi);

Mm DLLI interp1(Mm x, Mm y, Mm xi, cMm method);

Mm DLLI interp1q(cMm x, cMm y, cMm xi);

Mm DLLI interp2(cMm z);

Mm DLLI interp2(cMm z, Mm D);

Mm DLLI interp2(cMm z, Mm xi, Mm yi);

Mm DLLI interp2(cMm z, cMm xi, cMm yi, cMm method);

Mm DLLI interp2(cMm x, cMm y, cMm z, cMm xi, cMm yi);

Mm DLLI interp2(Mm x, Mm y, Mm z, Mm xi, Mm yi, cMm method);

Mm DLLI interp3(cMm v);

Mm DLLI interp3(cMm v, cMm D);

Mm DLLI interp3(cMm v, cMm D, cMm method);

Mm DLLI interp3(cMm v, cMm xi, cMm yi, cMm zi);

Mm DLLI interp3(cMm v, cMm xi, cMm yi, cMm zi, cMm method);

Mm DLLI interp3(cMm v, cMm xi, cMm yi, cMm zi, cMm method, cMm dummy);

Mm DLLI interp3(cMm x, cMm y, cMm z, cMm v, cMm xi, cMm yi, cMm zi);

Mm DLLI interp3(Mm x, Mm y, Mm z, Mm v, Mm xi, Mm yi, Mm zi, cMm method);

Mm DLLI tsearch(cMm x, cMm y, cMm tri, cMm xi, cMm yi);

Mm DLLI mkpp(Mm b);

Mm DLLI mkpp(Mm b, Mm c);

Mm DLLI poly(cMm x);

Mm DLLI polyder(cMm x);

Mm DLLI polyder(cMm x, cMm y);

Mm DLLI polyder(cMm x, i_o_t, Mm[$ a, Mm& b)]

Mm DLLI polyder(cMm x, cMm y, i_o_t, Mm[$ a, Mm& b)]

Mm DLLI polyfit(cMm x);

Mm DLLI polyfit(cMm x, cMm y);

Mm DLLI polyfit(cMm x, cMm y, cMm n);

Mm DLLI polyfit(Mm x, Mm y, cMm n, i_o_t, Mm[$ p, Mm& s)]

Mm DLLI polyval(Mm p);

Mm DLLI polyval(Mm p, Mm x);

Mm DLLI polyvalm(cMm p);

Mm DLLI polyvalm(cMm p, cMm x);

Mm DLLI ppval(Mm p);

Mm DLLI ppval(cMm p, Mm x);

Mm DLLI roots(Mm p);

Mm DLLI spline(Mm x);

Mm DLLI spline(cMm x, cMm y);

Mm DLLI spline(cMm x, cMm y, cMm x2);

Mm DLLI ss2tf(cMm a, cMm b, cMm c, cMm d, i_o_t, Mm[$ num, Mm& den)]

Mm DLLI ss2tf(cMm a, Mm b, cMm c, Mm d, cMm iu, i_o_t, Mm[$ num, Mm& den)]

Mm DLLI ss2zp(cMm a, cMm b, cMm c, cMm d, i_o_t, Mm[$ z, Mm& p, Mm& k)]

Mm DLLI ss2zp(cMm a, cMm b, cMm c, cMm d, i_o_t, Mm[$ z, Mm& p)]

Mm DLLI ss2zp(cMm a, cMm b, cMm c, cMm d, cMm iu, i_o_t, Mm& z, Mm& p, Mm& k );

Mm DLLI tf2ss(Mm num, Mm den, i_o_t, Mm[$ a, Mm& b, Mm& c, Mm& d)]

Mm DLLI tf2zp(cMm num, cMm den, i_o_t, Mm[$ z, Mm& p)]

Mm DLLI tf2zp(Mm num, Mm den, i_o_t, Mm[$ z, Mm& p, Mm& k)]

Mm DLLI unmkpp(cMm pp, i_o_t, Mm[$ b, Mm& c, Mm& l, Mm& k)]

Mm DLLI zp2tf(cMm z, cMm p, Mm k, i_o_t, Mm[$ num, Mm& den)]

Mm DLLI zp2ss(Mm z, Mm p, cMm k, i_o_t, Mm[$ a, Mm& b, Mm& c, Mm& d)]

Mm DLLI constr(cMm func);

Mm DLLI constr(cMm func, cMm x0);

Mm DLLI constr(cMm func, cMm x0, cMm options);

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb);

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub);

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad);

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, cMm varargin);

Mm DLLI constr(cMm func, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI constr(cMm func, cMm x0, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI constr(cMm func, cMm x0, cMm options, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, i_o_t, Mm& x, Mm& options_o);

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, i_o_t, Mm& x , Mm[$ options_o)]

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI constr(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, cMm varargin, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func);

Mm DLLI curvefit(cMm func, cMm x0);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options, cMm grad);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options, cMm grad, cMm varargin);

Mm DLLI curvefit(cMm func, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func, cMm x0, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, i_o_t, Mm& x, Mm& options_o);

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options, cMm grad, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI curvefit(cMm func, cMm x0, cMm xdata, cMm ydata, cMm options, cMm grad, cMm varargin, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI fmin(cMm func);

Mm DLLI fmin(cMm func, cMm a);

Mm DLLI fmin(cMm func, cMm a, cMm b);

Mm DLLI fmin(cMm func, cMm a, cMm b, cMm options);

Mm DLLI fmin(cMm func, cMm a, cMm b, cMm options, cMm varargin);

Mm DLLI fmin(cMm func, i_o_t, Mm[$ xo, Mm& options_o)]

Mm DLLI fmin(cMm func, cMm a, i_o_t, Mm[$ xo, Mm& options_o)]

Mm DLLI fmin(cMm func, cMm a, cMm b, i_o_t, Mm[$ xo, Mm& options_o)]

Mm DLLI fmin(cMm func, cMm a, cMm b, cMm options, i_o_t, Mm& xo, Mm& options_o);

Mm DLLI fmin(cMm func, cMm a, cMm b, cMm options, cMm varargin, i_o_t, Mm& xo, Mm[$ options_o)]

Mm DLLI fmins(cMm func);

Mm DLLI fmins(cMm func, cMm x);

Mm DLLI fmins(cMm func, cMm x, cMm options);

Mm DLLI fmins(cMm func, cMm x, cMm options, cMm grad);

Mm DLLI fmins(cMm func, cMm x, cMm options, cMm grad, cMm varargin);

Mm DLLI fmins(cMm func, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fmins(cMm func, cMm x, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fmins(cMm func, cMm x, cMm options, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fmins(cMm func, cMm x, cMm options, cMm grad, i_o_t, Mm& x_o, Mm& options_o);

Mm DLLI fmins(cMm func, cMm x, cMm options, cMm grad, cMm varargin, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fminu(cMm func);

Mm DLLI fminu(cMm func, cMm x);

Mm DLLI fminu(cMm func, cMm x, cMm options);

Mm DLLI fminu(cMm func, cMm x, cMm options, cMm grad);

Mm DLLI fminu(cMm func, cMm x, cMm options, cMm grad, cMm varargin);

Mm DLLI fminu(cMm func, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fminu(cMm func, cMm x, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fminu(cMm func, cMm x, cMm options, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fminu(cMm func, cMm x, cMm options, cMm grad, i_o_t, Mm& x_o, Mm& options_o);

Mm DLLI fminu(cMm func, cMm x, cMm options, cMm grad, cMm varargin, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI foptions();

Mm DLLI foptions(Mm options);

Mm DLLI fsolve(cMm func);

Mm DLLI fsolve(cMm func, cMm x);

Mm DLLI fsolve(cMm func, cMm x, cMm options);

Mm DLLI fsolve(cMm func, cMm x, cMm options, cMm grad);

Mm DLLI fsolve(cMm func, cMm x, cMm options, cMm grad, cMm varargin);

Mm DLLI fsolve(cMm func, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fsolve(cMm func, cMm x, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fsolve(cMm func, cMm x, cMm options, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fsolve(cMm func, cMm x, cMm options, cMm grad, i_o_t, Mm& x_o, Mm& options_o);

Mm DLLI fsolve(cMm func, cMm x, cMm options, cMm grad, cMm varargin, i_o_t, Mm[$ x_o, Mm& options_o)]

Mm DLLI fzero(cMm func);

Mm DLLI fzero(cMm func, cMm x);

Mm DLLI fzero(cMm func, cMm x, cMm tol);

Mm DLLI fzero(cMm func, cMm x, cMm tol, cMm trace);

Mm DLLI fzero(cMm func, cMm x, cMm tol, cMm trace, cMm varargin);

Mm DLLI quad(cMm func);

Mm DLLI quad(cMm func, cMm a);

Mm DLLI quad(cMm func, cMm a, cMm b);

Mm DLLI quad(cMm func, cMm a, cMm b, cMm tol);

Mm DLLI quad(cMm func, cMm a, cMm b, cMm tol, cMm trace);

Mm DLLI quad(cMm func, cMm a, cMm b, cMm tol, cMm trace, cMm varargin);

Mm DLLI conls(cMm C);

Mm DLLI conls(cMm C, cMm d);

Mm DLLI conls(cMm C, cMm d, cMm A);

Mm DLLI conls(cMm C, cMm d, cMm A, cMm b);

Mm DLLI conls(cMm C, cMm d, cMm A, cMm b, cMm vlb);

Mm DLLI conls(cMm C, cMm d, cMm A, cMm b, cMm vlb, cMm vub);

Mm DLLI conls(cMm C, cMm d, cMm A, cMm b, cMm vlb, cMm vub, cMm x0);

Mm DLLI conls(cMm C, cMm d, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, cMm neq)

;

Mm DLLI lp(cMm c);

Mm DLLI lp(cMm c, cMm A);

Mm DLLI lp(cMm c, cMm A, cMm b);

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb);

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub);

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0);

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, cMm neq);

Mm DLLI lp(cMm c, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI lp(cMm c, cMm A, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI lp(cMm c, cMm A, cMm b, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, i_o_t, Mm& x, Mm&lam);

Mm DLLI lp(cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, cMm neq, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI nnls(cMm A);

Mm DLLI nnls(cMm A, cMm b);

Mm DLLI nnls(cMm A, cMm b, i_o_t, Mm[$ x, Mm& w)]

Mm DLLI nnls(cMm A, cMm b, i_o_t, Mm[$ x, Mm& w, Mm& err)]

Mm DLLI qp(cMm Q);

Mm DLLI qp(cMm Q, cMm c);

Mm DLLI qp(cMm Q, cMm c, cMm A);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, cMm neq);

Mm DLLI qp(cMm Q, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI qp(cMm Q, cMm c, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI qp(cMm Q, cMm c, cMm A, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub, i_o_t, Mm& x, Mm& l

am);

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, i_o_t, Mm&x, Mm[$ lam)]

Mm DLLI qp(cMm Q, cMm c, cMm A, cMm b, cMm vlb, cMm vub, cMm x0, cMm neq, i_o_t, Mm[$ x, Mm& lam)]

Mm DLLI minimax(cMm func);

Mm DLLI minimax(cMm func, cMm x0);

Mm DLLI minimax(cMm func, cMm x0, cMm options);

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb);

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub);

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad);

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, cMm varargin);

Mm DLLI minimax(cMm func, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI minimax(cMm func, cMm x0, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI minimax(cMm func, cMm x0, cMm options, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, i_o_t, Mm& x, Mm& options_o);

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, i_o_t, Mm&x, Mm[$ options_o)]

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI minimax(cMm func, cMm x0, cMm options, cMm vlb, cMm vub, cMm grad, cMm varargin, i_o_t, Mm[$ x, Mm& options_o)]

Mm DLLI odeget(cMm options);

Mm DLLI odeget(cMm options, cMm n);

Mm DLLI odeget(cMm options, cMm n, cMm def);

Mm DLLI odeset();

Mm DLLI odeset(cMm n1);

Mm DLLI odeset(cMm n1, cMm v1);

Mm DLLI odeset(cMm opts, cMm n1, cMm v1);

Mm DLLI odeset(cMm n1, cMm v1, cMm n2, cMm v2);

Mm DLLI odeset(cMm opts, cMm n1, cMm v1, cMm n2, cMm v2);

Mm DLLI odeset(cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3);

Mm DLLI odeset(cMm opts, cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3);

Mm DLLI odeset(cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3, cMm n4, cMm v4);

Mm DLLI odeset(cMm opts, cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3, cMmn4, cMm v4);

Mm DLLI odeset(cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3, cMm n4, cMm v4, cMm n5, cMm v5);

Mm DLLI odeset(cMm opts, cMm n1, cMm v1, cMm n2, cMm v2, cMm n3, cMm v3, cMmn4, cMm v4, cMm n5, cMm v5);

Mm DLLI ode23(cMm func);

Mm DLLI ode23(cMm func, cMm tspan);

Mm DLLI ode23(cMm func, cMm tspan, cMm y0);

Mm DLLI ode23(cMm func, cMm tspan, cMm y0, cMm options);

Mm DLLI ode23(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin);

Mm DLLI ode23(cMm func, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode23(cMm func, cMm tspan, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode23(cMm func, cMm tspan, cMm y0, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode23(cMm func, cMm tspan, cMm y0, cMm options, i_o_t, Mm& tout, Mm& yout);

Mm DLLI ode23(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin, i_o_t,Mm[$ tout, Mm& yout)]

Mm DLLI ode45(cMm func);

Mm DLLI ode45(cMm func, cMm tspan);

Mm DLLI ode45(cMm func, cMm tspan, cMm y0);

Mm DLLI ode45(cMm func, cMm tspan, cMm y0, cMm options);

Mm DLLI ode45(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin);

Mm DLLI ode45(cMm func, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode45(cMm func, cMm tspan, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode45(cMm func, cMm tspan, cMm y0, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode45(cMm func, cMm tspan, cMm y0, cMm options, i_o_t, Mm& tout, Mm&yout);

Mm DLLI ode45(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin, i_o_t,Mm[$ tout, Mm& yout)]

Mm DLLI ode78(cMm func);

Mm DLLI ode78(cMm func, cMm tspan);

Mm DLLI ode78(cMm func, cMm tspan, cMm y0);

Mm DLLI ode78(cMm func, cMm tspan, cMm y0, cMm options);

Mm DLLI ode78(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin);

Mm DLLI ode78(cMm func, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode78(cMm func, cMm tspan, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode78(cMm func, cMm tspan, cMm y0, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode78(cMm func, cMm tspan, cMm y0, cMm options, i_o_t, Mm& tout, Mm&yout);

Mm DLLI ode78(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin, i_o_t,Mm[$ tout, Mm& yout)]

Mm DLLI ode15s(cMm func);

Mm DLLI ode15s(cMm func, cMm tspan);

Mm DLLI ode15s(cMm func, cMm tspan, cMm y0);

Mm DLLI ode15s(cMm func, cMm tspan, cMm y0, cMm options);

Mm DLLI ode15s(cMm func, cMm tspan, cMm y0, cMm options, cMm varargin);

Mm DLLI ode15s(cMm func, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode15s(cMm func, cMm tspan, i_o_t, Mm[$ tout, Mm& yout)]

Mm DLLI ode15s(cMm func, cMm tspan, cMm y0, i_o_t,  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: webycn

Posted on: 2002-10-18 14:38

MATCOM已經被MATHTOOLS收購了,沒有新版的matcom了。:!(

從matlab65的線上幫助中,搜集了一些東西,希望對大家有用。  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: wcs6208

Posted on: 2002-10-18 15:44

還是小和尚功力高!!  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: future

Posted on: 2002-10-18 17:02

請問能不能上傳最新的matcom,還有我想問一個想生成stand-alone的程式時,要不要先安裝C/C++。  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: 小和尚

Posted on: 2002-10-18 19:10

其實新版的matlab6.5自帶的compile,不用matcom了,也不用裝c,可以做成獨立的exe檔案.  

--------------------------------------------------------------------------------

回複: (轉貼)Matlab與C++接口與混合程式設計讨論小結 Copy to clipboard

Posted by: greenbow

Posted on: 2002-10-19 13:53

matlab6.0(R12) stand-alone方式

Solution Number: 27257

Date Last Modified: 2002-05-24

Product: MATLAB C/C++ Math Library 2.1 ==> Current Version

Platform: Windows

Problem Description

How do I create a stand-alone C or C++ executable in the Microsoft Visual C/C++ 6.0 IDE from the project files in $MATLAB/extern/examples/cmath or $MATLAB/extern/examples/cppmath using MATLAB 6.0 (R12)?

Are the project files in $MATLAB/extern/examples/cmath or cppmath updated for use with the C++ Math Library 2.1?

Solution:

The project files in the $MATLAB/extern/examples/cmath and cppmath directories were not changed for versions 1.2, 2.0, or 2.1 of the MATLAB C/C++ Math Library. The project files are the same files that were available in version 1.1 of the MATLAB C/C++ Math Library.

In general it is not practical for us to offer complete technical support on the details of using any specific one of the large number of IDE environments our customers use. If you need detailed assistance with the particular settings needed to get your IDE environment to generate code that successfully compiles and runs with our products, please contact the manufacturer of your IDE to get information or expert technical assistance in using it.

NOTE: The following solution is to be used ONLY with the MATLAB C/C++ Math Library 2.1, released with MATLAB 6.0 (R12). If you have a version of the C/C++ Math Libraries previous to 2.1 please use solution 21291. You can find solution 21291 at the following location:

http://www.mathworks.com/support/solutions/data/21291.shtml

If you do not have MATLAB 6.0, please use the following steps to create a stand-alone C or C++ executable with the Microsoft Visual C/C++ 6.0 IDE and C/C++ Math Libraries 2.1:

1. Start up the Microsoft Visual C/C++ 6.0 IDE

2. Go to FILE and NEW. Click on Projects Tab. Select Win32 Console Application. In the Project Name field type: ex1. Create new workspace should be filled in. In the Platforms field, Win32 should also be checked. Click OK.

3. Highlight ex1 files and then right click. Select Settings. Click on the C/C++ Tab. In the Category listbox select Code Generation. In the Use Runtime library listbox select Multithreaded DLL. Change the Category listbox to Preprocessor. Add to the Preprocessor definitions _WINDOWS, _AFXDLL,IBMPC, MSVC, MSWIND, __STDC__ so:

WIN32,_DEBUG,_CONSOLE,_MBCS

changes to:

WIN32,_DEBUG,_CONSOLE,_MBCS,_WINDOWS,_AFXDLL,IBMPC,MSVC,MSWIND,__STDC__

Add to the Additional include directories field:

$MATLAB\extern\include (where $MATLAB is your root directory)

NOTE: If you are using the C++ Math Library then also add

$MATLAB\extern\include\cpp

Click on the Link Tab. In the Category listbox select Input. For C applications, the Object/Library modules field would change from:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

to:

libmmfile.lib libmatlb.lib libmx.lib libmat.lib sgl.lib libmwsglm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Add the libraries path under Additional library path:

$MATLAB\extern\lib\win32\microsoft\msvc60

NOTE: If you are creating C++ executables you will need to add libmatpm.lib also to the Object/Library modules field. Also add the following library path under Additional library path:

$MATLAB\extern\lib\win32

Click OK.

4. Go to Build and Rebuild All.

5. Go to Build and Execute ex1.exe.