In Matlab, is it possible to terminate a script, but save all its internal variables to workspace?

前端 未结 3 1294
不思量自难忘°
不思量自难忘° 2020-12-01 08:05

I am running a script, but it is taking much too long so I want to terminate the script. However it has calculated a lot of data which I would ideally not want to throw away

3条回答
  •  难免孤独
    2020-12-01 08:41

    MATLAB versions 2016a and later

    If you are using post 2016a versions of Matlab there is actually a pause button that appears when you run the script (as described by @pedre). This allows you to pause the script, inspect variables and then resume afterwards.

    Make sure to check out the next section as this may still be convenient.

    Older MATLAB versions

    Actually the trick is to use dbstop if error.

    First use this, then run your script. Once you introduce an error (for example, with Ctrl+C), you then have the chance to inspect/save your workspaces manually.

    You will not be able to resume the script.

提交回复
热议问题