How to run automatically an .m code everyday in a specified time

16 ビュー (過去 30 日間)
Vahid
Vahid 2012 年 7 月 13 日
Hi folks,
I have a specific .m function which should be called in MATLAB command window every day in a specified time, but I am wondering whether there is a way to do that?
as a background information, I run MATLAB on MAC OS X.

回答 (1 件)

Thomas
Thomas 2012 年 7 月 13 日
編集済み: Thomas 2012 年 7 月 13 日
Since you are on a mac you need to setup a cron job to run daily.
Your command could be something like
matlab -r your_mfile;quit
or
path/to/matlab -r path/to/mfile;quit
if you do not have the path to MATLAB setup and the m file is not on you matlab path.
You may also want the -nodesktop and -nosplash startup options.
OR
You could keep MALTAB running execute as shown in the following link http://www.mathworks.com/matlabcentral/newsreader/view_thread/259469.
I would personally go for the cron job since I donot need to MATLAB runnign all the time..
  3 件のコメント
Thomas
Thomas 2012 年 7 月 13 日
Is the m file on your matlab path? It makes it a lot easier if you do not have to specify the path but should work.. please add it Users/YOURNAMEHERE/Documents/MATLAB directory which should be on the path and run the following from the terminal..
/Applications/MATLAB_R2011a.app/bin/matlab -nosplash -nodesktop -r youmfilenamewithoutextension
Does it work now? if so then you can add this to your cron
It must work from the terminal..
Vahid
Vahid 2012 年 7 月 13 日
the m file is not located in the MATLAB path. I opened the MATLAB from terminal:
/Applications/MATLAB_R2010bSP1.app/bin/matlab -nosplash -nodesktop -r myfunction
but I recieved the following error:
Undefined function or variable 'myfunction'.
what should I do now?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by