Is it possible to save a workspace when a program is paused without it ending the program?

조회 수: 23 (최근 30일)
I have been running a program for the last few days that I realized will give me an error eventually. However it won't be an issue if I can save the workspace before that happens.
I know that trying to save a function or script while a program is running will make the program quit. So I don't want to do that here, especially if it will not save the workspace.
I also currently have pausing at errors enabled. So will that pause without terminating the workspace and let me save it?
  댓글 수: 1
Stephen23
Stephen23 2020년 5월 23일
It is unclear what you actually mean by "pause":
  • the function pause, in which case the answer is "not easily".
  • debugging features which stop code evaluation on error, e.g. dbstop, in which case the answer is "yes".

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2020년 5월 23일
Using the save function at appropriate places in the code will not cause the code to crash.
See: How to save data from Genetic Algorithm in case MATLAB crashes? for an illustration of one way to save the relevant variables in (what appears to be) a similar context.
  댓글 수: 4
Goran Prpic
Goran Prpic 2020년 5월 23일
so to clarify.
There were situations from before where I was running a program while writing some code for a function (not sure if it was the function that was running or another function). But when I pressed the button for saving the functions, the program that was running quit debugging, it stopped.
So the reason why I don't want to just pause and save the workspace is because I am afraid that the program that is currently running will quit and my progress will be lost (or at best, in case it does save the workspace, continuing from where it stopped would be kind of a big pain).
Star Strider
Star Strider 2020년 5월 23일
The function that I implemented to record the current variables in that Answer is just another function call. It does not pause or interrupt anything, it simply executes and then passes control back to the calling script.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by