dos command line invocation

7 views (last 30 days)
ovi chitayat
ovi chitayat on 4 May 2011
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?

Accepted Answer

Jason Ross
Jason Ross on 4 May 2011
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 Comments
ovi chitayat
ovi chitayat on 4 May 2011
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 on 4 May 2011
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!