Matlab: Running an m-file from command-line

hkBattousai picture hkBattousai · Jul 11, 2011 · Viewed 187.7k times · Source

Suppose that;

I have an m-file at location:
C:\M1\M2\M3\mfile.m

And exe file of the matlab is at this location:
C:\E1\E2\E3\matlab.exe

I want to run this m-file with Matlab, from command-line, for example inside a .bat file. How can I do this, is there a way to do it?

Answer

hkBattousai picture hkBattousai · Jul 16, 2011

A command like this runs the m-file successfully:

"C:\<a long path here>\matlab.exe" -nodisplay -nosplash -nodesktop -r "run('C:\<a long path here>\mfile.m'); exit;"