I'm working with Matlab on a server cluster, therefore I have no display and use it via command line. Running scripts works fine with
matlab -nodesktop -nosplash my_script
To save the output to a log and quit Matlab after execution of my_script
, I modified the command as follows:
matlab -nodesktop -nosplash -r "try, my_script; end, quit force" | tee simple.log
However, error messages that are displayed in the Matlab Desktop version are not displayed in the log, which makes debugging very difficult.
Is there a way to store matlabs output with error messages in a log?
Assuming you are running on Linux, refer to these command line arguments. To get the output of matlab into a file you can call
matlab -nosplash -nodesktop -logfile my.log -r "try; ...; catch e;.. "
From the documentation
-logfile filename
Copy Command Window output, including error reports, into filename, specified as a string.