MATLAB: How to call a matlab function from an excel macro

call matlabexcel macro

Hi,
I'm creating an excel vba macro. I want to call and open matlab with a specific function by clicking the macro.
Is this possible?
Thanks,

Best Answer

I can do basic things like plot graphs, create variables using this script but as soon as I tell it to run a script it freezes and excel starts giving this message:
'Microsoft Excel is waiting for another programme to complete an OLE Command'
This is the script I used:
Dim MatLab As Object
Sub RunMatlabDayfiletool()
'Create the Matlab Object
Set MatLab = CreateObject("Matlab.Application")
Result = MatLab.Execute("cd('\\Directory')")
Result = MatLab.Execute("x = -pi:.1:pi; y = sin(x); plot(x,y)")
End Sub
Related Question