2

Following some great advices, as this: suppress start message of Matlab I now use this line to execute Matlab script from within my preferred editor, without launching whole Matlab machinery:

matlab -nosplash -nojvm -logfile /tmp/matlab-log -wait < "$(FilePath)" \
> /dev/null 2 && sed '1,9d' /tmp/matlab-log

-nodisplay switch is omitted as I want to be able to see plot output.

However, when using above line to evoke script that produces plot, plot window appears and then immediately disappears.

How to keep plot window visible, considering above execution line?


I know I could add waitforbuttonpress; in each plot script, but looking for something more automatic w/o complicating execution line too much

Community
  • 1
  • 1
theta
  • 24,593
  • 37
  • 119
  • 159

2 Answers2

0

Try using the command uiwait in your script.

f =  figure();
uiwait(f);
Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
  • It's similar as adding `waitforbuttonpress;` inside script. I'm looking for approach without changing Matlab script – theta Jan 16 '12 at 16:19
0

Presumably, your script contains an exit or quit statement, which is what causes MATLAB to close. You'd need to intercept that and wait for a keypress before actually quitting.

MATLAB runs the finish script before it closes, so you could use that. But it would need to be on the path.

Forgive me for asking, but is there a good reason you don't want to use the MATLAB editor?

Nzbuu
  • 5,241
  • 1
  • 29
  • 51
  • No, script does not contain exit or quit, and you can try for yourself with simple plot, if you can. I can't tell what Matlab shell script does exactly as it's ~ 2000 lines long, but maybe there is some reason. As for your question, there could be many reasons, starting from resource management to familiar user environment like preferred editor. If developing something, Matlab environment is great, but for usual script testing and simple function calculation, filter testing code etc.. there is no need for me to launch whole Matlab environment – theta Jan 16 '12 at 17:59
  • I made `finish.m` script with one line inside "waitforbuttonpress;" and copied it in my home folder, in folder where executed script is placed, in Matlab folder and in Matlab/toolbox/local. Plot is terminated in all cases – theta Jan 16 '12 at 18:08