2014-09-26 40 views
0
Private Sub CommandButton1_Click() 

    Dim MatLab As Object 
    Set MatLab = CreateObject("Matlab.Application") 
    MatLab.Execute ("a = 1") 
    MatLab.Execute ("disp(a)") 

End Sub 

我需要显示的值MATLAB变量“a”在MATLAB和显示窗口应该是我看到,检查命令是否执行或者不执行?我怎样才能打开使用VBA语句

回答

0

一种方法是在MATLAB中编写代码,并使用VBA作为shell来执行该功能。

在VBA中,您可以像这样使用shell

shell "C:\Matlab2011a\matlab.exe -r your_function_name 

,并在你的Matlab代码

function yourFunction() 
    cd('C:\yourDirectory'); % moves you to your desired directory 
          % your code here 
    exit;     % exits Matlab 
end 

方法二:

您可以使用SpreadSheet Link EX并呼吁matlabinit功能。