interactive vs batch ?

8 ビュー (過去 30 日間)
Clark
Clark 2012 年 1 月 23 日
Hey all;
We've been looking for a good way to select whether to call 'exit' vs. 'return' when leaving an m file. In interactive mode we want to call 'return' when debugging a batch script, and in batch mode we'd like to call 'exit'.
Since we apparently do not know what we are doing :) we have a lot of these:
if( interactive ), return;, else, exit;, end
laying around, where 'interactive' is a variable we have kluuged up. Clearly this added apparatus of ours is not optimal. If we could detect the '-nodesktop' setting from within an m file, then we could automate it a little more. I suspect we are barking up the wrong tree altogether.
What's the big picture, what are we missing? THANK YOU
Oh, We invoke batch processing from bash on Ubuntu 10.04 thus:
matlab -logfile $MATLAB_LOG_FILE -nosplash -nodesktop -r "mProc();"
  3 件のコメント
Clark
Clark 2012 年 1 月 24 日
Thanks Andrew!
Matlab simply returns to the command prompt if you don't call 'exit' ie, it never exits. That's not good. We need it out of the way to make room for the next job.
Clark
Clark 2012 年 1 月 24 日
Oh and you can guess the rest. Because we don't have the luxury of allowing our 1000s of jobs to back up, we avoid usage of error() in our batch scripts, because it also lands matlab waiting at the command prompt without exiting. And since there appears to be no way to return a status from an m file back through to the calling bash script (ie $?), we have taken to the outlandish scheme of writing a message on the last line of the "-logfile $MATLAB_LOG_FILE' as our means of "IPC." (See, I told you we don't know what we are doing!)
I think we're missing something basic (besides brain cells)

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 1 月 24 日
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 1 月 24 日
matlab -logfile $MATLAB_LOG_FILE -nosplash -nodesktop -r "try mProc();catch;end;quit"
Clark
Clark 2012 年 1 月 24 日
Hey Walter, thanks.
Fearful that try/catch might suppress output, we have only braved it as far as:
matlab -logfile $MATLAB_LOG_FILE -nosplash -nodesktop -r "mProc();exit;"
so far.
If that's the word on what we've got, then I'll take the plunge and convert all of our jobs to this scheme. It would be nice if there were a way to control the action at some higher level.
We're also considering devising our own "quit" and error functions, and having them check an environment variable to control the action. That might not be too bad.
When I ported Processing (processing.org) as a new plotting engine for Matlab, I discovered the structure of java within Matlab, and I can see why returning a status is not as easy as it sounds.

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

カテゴリ

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