interactive vs batch ?

8 views (last 30 days)
Clark
Clark on 23 Jan 2012
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 Comments
Clark
Clark on 24 Jan 2012
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 on 24 Jan 2012
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)

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 24 Jan 2012
  2 Comments
Walter Roberson
Walter Roberson on 24 Jan 2012
matlab -logfile $MATLAB_LOG_FILE -nosplash -nodesktop -r "try mProc();catch;end;quit"
Clark
Clark on 24 Jan 2012
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.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!