Run MATLAB as background job

As continuation of my last post, I got a very useful trick of running MATLAB namely to run it as background job.

I am running an optimization problem in MATLAB with hundreds of optimized variables, so it may take  around 30 minutes or more to finish.  The trick is to make a script as following :

#!/bin/csh -f

unsetenv DISPLAY

nohup matlab < $1 > $2 &

save it as matbg and make it as executable, chmod +x matbg.

$1 is your matlab m file and $2 is an output file. For example, you run it: matbg optim.m result.

It is an excellent script. It means I can leave my simulation running while I am doing other activities 🙂

Similarly, I can use that script for other programs in UNIX server just by changing the program name.

All you need with MATLAB

As an engineering or science student, it is unavoidable to simulate a concept or method that we propose in a computer simulation. MATLAB is the most preferable one. I found a website which I think collect everything needed to be a good matlab coder.

Here you go: http://www.ee.columbia.edu/~marios/matlab/matlab_tricks.html

If you manage to find better websites, please let me know..