can i pause matlab excution while it is already running
62 ビュー (過去 30 日間)
古いコメントを表示
hi every on ,
can i pause matlab excution while it is already running
(i.e) if i have a script and is already running can i pause it for any time then resuming it again .
thanks a lot .
2 件のコメント
LJ
2015 年 7 月 12 日
You can use this clever function the next time. It will allow you to pause the execution any time you want just with the click of a button and then you can resume it pressing F5.
Walter Roberson
2016 年 5 月 31 日
That will not work unless there is a figure() or drawnow() or pause() or waitfor() or uiwait() somewhere in the code. Pushbuttons are not serviced until the graphics queue is processed, which requires one of the above to happen.
回答 (6 件)
Image Analyst
2016 年 5 月 31 日
With R2016a, there is now a Pause button on the tool ribbon that appears when your code runs:
0 件のコメント
Nick Hilton
2015 年 10 月 12 日
If you're on a UNIX platform, then there is an easy way to do this:
Simply run your script on the command line in a BASH shell like so:
matlab -nodesktop -nosplash -r "run_some_script(arg1, arg2, ...)"
Now that it is running, you can pause execution by pressing CTRL+Z, which pauses execution and returns you to the BASH prompt again. To continue execution, execute the 'fg' command to put the suspended job back into the foreground.
Another advantage to this approach, most graphical terminals provide an output buffer, and one can scroll and examine the output buffer without pausing the execution, and without new output causing the buffer to scroll the screen. So I can look at the buffer to tell where the execution is in a loop, for example, without pausing anything.
I hope this helps someone that finds this topic.
3 件のコメント
Benoit Espinola
2018 年 9 月 13 日
This is gold!
"Another advantage to this approach, most graphical terminals provide an output buffer, and one can scroll and examine the output buffer without pausing the execution, and without new output causing the buffer to scroll the screen. So I can look at the buffer to tell where the execution is in a loop, for example, without pausing anything."
And how can we consult this output buffer?
Would you say that consulting the output buffer could give me information on the state of the execution of the code?
Many thanks,
Benoit
Walter Roberson
2018 年 9 月 15 日
To consult the output buffer, use the Page Up / Page Down keys, or use whatever scrollbar your terminal application provides. Here, "output buffer" refers a configurable number of lines of stdout .
For example on OS-X, inside the Terminal.app utility, Preferences -> Profiles -> Window permits me to configure whether I want scrollback to be limited to available memory, or to a specific number of output lines.
Mahdi
2013 年 3 月 27 日
You can pause the script/function that you're running for a specified amount of time without quitting the script.
If you're using a GUI, I would suggest looking at uiwait.
0 件のコメント
Jan
2013 年 3 月 26 日
No.
2 件のコメント
Jan
2013 年 3 月 26 日
Sorry, I did not want to pollute my answer by too many details: You can stop the execution by hitting Ctrl-C, but afterwards you cannot resume.
Actually, the results must be correct, if you force the computer to fall asleep, e.g. a hibernation. But I would test this exahsutively before I'd trust the results.
Omer Moussaffi
2014 年 12 月 14 日
Not without preparation. You could add the command 'keyboard' into the script at a specified place, and then it would give you back control. You then do your changes, and either call 'return' to resume or dbquit to stop the script.
0 件のコメント
jingxuan yang
2020 年 3 月 24 日
use
uiwait
to pause
and use
uiresume
to continue
1 件のコメント
Walter Roberson
2020 年 3 月 25 日
Yes, if you have the cooperation of the code being run, if it knows that you should pause there, or if it regularly calls one of the functions such as drawnow() that processes the event queue to permit a callback to be triggered to run the uiwait()
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!