2012-08-15 136 views
0

请帮我解决这个问题。如何用VBA打开matlab

问题是如何从VB excel打开matlab。 我已使用代码"matlabinit"。但是当我在VB excel中运行它时,我可以打开matlab应用程序,但打开的当前目录不喜欢我想要的。我想从VB excel打开matlab与特定的currect目录,因为我想要的。

感谢您的回答。

回答

1

最简单的方法就是调用matlab函数change the current folder。这种方式将特定于您的项目。所以就把这条线在您开始用MATLAB互动的开始:

MLEvalString "cd('C:\MyFolder')" 
+0

感谢您Mr.Dan先生,你能不能帮我解决我的问题在这个环节? http://stackoverflow.com/questions/11965330/how-to-make-faster-looping – 2012-08-15 13:15:34

+3

不,这个问题是不可理解的。 – Dan 2012-08-15 13:20:10

0

你可以找到如何做的说明here

您使用shell在VBA运行MATLAB,大致是这样的:

在VBA

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 

或者,你可以管理你的VB目录本身通过使用在此发现的方法previous post

+0

谢谢你这么多@Salain – 2012-08-15 13:15:53