Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Matlab output to command line

Tags:

matlab

I am running a MATLAB script from the Windows command prompt:

"C:\Program Files\MATLAB\R2014B\bin\matlab" -nodisplay -nosplash -nodesktop -wait -r "test.m"

The test.m is simple:

function test
disp('Hello!');

The output is displayed in the Matlab Command Window. Is there any way how I can force output to the windows prompt?

like image 345
Anton Avatar asked Aug 31 '25 01:08

Anton


2 Answers

Use the command line option -log when you call Matlab from the command line (or any other shell or batch (e.g. cmd or bat) script).
It isn't documented as of Matlab 2017b, but it works.

Side note: -nodisplay isn't supported in the Windows version of Matlab, but if you want to prevent it from displaying figures, use -noFigureWindows instead.

like image 119
Adrian Avatar answered Sep 05 '25 14:09

Adrian


Since R2019b, there is a new command line option, -batch, which redirects the output to the command line and handles other stuff for batch processing. See the documentation for Windows.

matlab -batch "statement to run"

This starts MATLAB without the desktop or splash screen, logs all output to stdout and stderr, exits automatically when the statement completes, and provides an exit code reporting success or error.

like image 29
Cris Luengo Avatar answered Sep 05 '25 13:09

Cris Luengo