free hit counter

Tuesday, May 18, 2010

exit(-1) in matlab *does* work

Experimentation shows that this matlab command wrapped in a perl script does do what you would expect it to do, contrary to documentation.

$status= system("matlab.exe -nosplash -nojvm -nodisplay -wait -r \"exit(1)\"");

print "\n\nmatlab exited with status: $status\n";

Why should I be surprised?

Matlab is a terrible hodge-podge and that's why I think people like it so much. Just like Perl, or labyrinthine city streets. Still, it's not my kind of city, even if I have to visit all the time.

If you're silly enough to read the documentation, the exit function doesn't take an integer argument for the process return value:

>> help exit
EXIT Exit from MATLAB.
EXIT terminates MATLAB after running finish.m, if finish.m exists.
It is the same as QUIT and takes the same termination options.
For more information, see the help for QUIT.

See also quit.

Reference page in Help browser
doc exit

Further reading through the help and doc results of quit show no numeric arguments for process return values.

Labels: ,


Post a Comment

<< Home