script sh to run a matlab program

i have to run a matlab program in background on a remote server, using a bourne shell. i tried to figure out what i have to do on the web, but i still haven't managed to do it.
i tried with the script try.sh:
#!/bin/sh
matlab my_prog.m output &
with my_prog.m the test program:
ok_string='ok';
save('ok.mat','ok_string')
which are my errors?

 Akzeptierte Antwort

Daniel Shub
Daniel Shub am 7 Mär. 2012

1 Stimme

I would change the script to be:
/full/path/to/matlab/binary/matlab -nodesktop -r my_prog
Note that the .m extension is left off the input script. Also, make sure you add
exit;
to the end of your m file. You also might want to hardcode the path in the m file.

3 Kommentare

Walter Roberson
Walter Roberson am 7 Mär. 2012
Small correction: do not put on the .m file extension:
/full/path/to/matlab/binary/matlab -nodesktop -r my_prog
Daniel Shub
Daniel Shub am 7 Mär. 2012
@Walter, thank you. Fixed.
Francesco
Francesco am 8 Mär. 2012
it worked, i forgot to add
exit
thank you all.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by