刚看到的。
http://www.ctex.org/forums/index.php?showtopic=7703
7)如何在Delphi中调用Matlab(ActiveX)?
:#FangQ(Qianqian.Fang@Dartmouth.Edu), 2002/6/22.BigGreen/MathTools#
从这个地址下载例子:
http://www.djpate.freeserve.co.uk/Matlab.htm
还有一种方法是利用DelphiMEX,下载地址:
http://Radio-BIP.qc.ca/DelphiMEX/DelphiMEX.html
下面是把Alex Conradie的例子中选了一些主要的语句:
var
V : Variant;
MReal : OleVariant;
MImage : OleVariant;
begin
i,j : integer;
MReal := VarArrayCreate([0, 1, 0, 3], varDouble);
MImage := VarArrayCreate([0,0,0,0], varDouble);
V := CreateOLEObject('Matlab.Application');
V.Execute('a=[1 2 3 4; 5 6 7 8]');
V.GetFullMatrix('a','base',VarArrayRef(MReal),VararrayRef(MImage));
for i := 0 to 1 do
for j := 0 to 3 do
Stringgrid1.Cells[j,i] := MReal[i,j];
V.Execute('peaks');
MReal := VarArrayCreate([0, 1, 0, 3], varDouble);
MImage := VarArrayCreate([0,0,0,0], varDouble);
for i := 0 to 1 do
for j := 0 to 3 do
MReal[i,j] := i+4;
V.PutFullmatrix('b','base',VarArrayRef(MReal),VararrayRef(MImage));
end