MATLAB script run through terminal

2 views (last 30 days)
Rupamathi Jaddivada
Rupamathi Jaddivada on 17 Jun 2017
Answered: Walter Roberson on 18 Jun 2017
Hi, I used the command 'matlab -r 'try filename(args); catch;end;quit' in order to run a simulation remotely. However, I don't know how to check the status of completion. I don't even know how to stop the simulation. Please let me know if there is anyway I can resolve these issues.
Thanks, Rupa

Answers (1)

Walter Roberson
Walter Roberson on 18 Jun 2017
The completion of the MATLAB command itself can be checked in most shells by looking at the $? variable; http://www.linuxnix.com/find-exit-status-script-command-linux/
If you are talking about the status of individual commands within the function, you can look at the standard output. If you want to write stdout to a file while still looking at it interactive, use the shell tee command. The question of when exactly MATLAB flushes its output buffer can be important in some cases.
You could also consider using the MATLAB diary command.
"I don't even know how to stop the simulation"
If you are running interactively in a shell, then unless you have altered your termios settings (by using the stty command, probably), you can control-c to interrupt the execution, or you can (probably) control-Z to pause the execution. Sometimes execution gets stuck beyond the ability of control-C to fix it, or if you are not running interactively, you may need to kill the process.

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!