dos command line invocation

Is there a way to just call matlab from a dos command, pass it a .m file, have it execute that .m file and exit quitely, possibly only returning a completion status?

 채택된 답변

Jason Ross
Jason Ross 2011년 5월 4일

0 개 추천

There are a number of options you can pass. In your case, I think you would use -minimize, -nosplash and the path to the m-file you wanted to run.
All the options are documented here:
The completion status can be a bit tricky, as I'm not 100% sure that %ERRORLEVEL% will be set correctly if there's an error in your program, since MATLAB may have "exited correctly". You would need to experiment with that, but it should be easy to test.

댓글 수: 4

Walter Roberson
Walter Roberson 2011년 5월 4일
Note: when you use the "-r" option, if your .m file does not already include "quit" or "exit", you should add that to the command line; for example,
matlab -r "mymfile;quit"
ovi chitayat
ovi chitayat 2011년 5월 4일
thank you Jason and Walter. I got enough info to chew on and try out. I appreciate.
ovi chitayat
ovi chitayat 2011년 5월 4일
i don't seem to be able to prevent the command window from showing up. My command line:
matlab -nosplash -nodesktop -noFigureWindows -automation -r "callMagic;quit"
ovi chitayat
ovi chitayat 2011년 5월 4일
scratch my last comment - the command window only shows up because there was an error in my callMagic. there ought to be a way to suppress that as well, but it is not a showstopper for me. thank you all again.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by