How to call a matlab function from an excel 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,

댓글 수: 3

Aadil
Aadil 2012년 8월 15일
anyone?
Dim MatLab As Object
Sub RunMatlabDayfiletool()
'Create the Matlab Object
Set MatLab = CreateObject("Matlab.Application")
Call MatLab.Execute("cd('D:\OLD')")
Call MatLab.Execute("AutoMakeFile.m")
End Sub
I ran this is vba, matlab opens up but doesn't run the script. When typing in 'cd' the path shown is the correct one
Can someone help with this?
Thanks
When I saw the example for this type of scripts in https://in.mathworks.com/help/matlab/ref/execute.html?searchHighlight=MatLab.Execute&s_tid=doc_srchtitle site I have observed that
Set Matlab = CreateObject("matlab.application")
but in your script it is different and try using "Feval" functionfor calling something in it.
for example check more about feval

댓글을 달려면 로그인하십시오.

 채택된 답변

Aadil
Aadil 2012년 8월 21일

0 개 추천

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

댓글 수: 1

Aadil
Aadil 2012년 8월 21일
OK looks like it runs the script but doesn't display the commands in the command window, everything runs invisibly
Any way round this?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

질문:

2012년 8월 15일

댓글:

2019년 11월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by