Why does Matlab not allow you to interupt a function mid execution?
3 views (last 30 days)
Show older comments
This is more a question directed towards the mathworks staff.
Why does MATLAB not let you interupt execution to see the variable values/ variables in scope etc.
I am familiar with the pause.m function, however this needs to be called from the command line and can not be called from the GUI.
in MS Visual Studio you can pause from the IDE and then start again. This is an excellent feature of the IDE.
I see a related post on the web here: http://scrolls.mafgani.net/2007/03/matlab-interrupting-function-execution/
Are there any plans to include a button on the IDE to do this?
Edited: Jason Ross on 13 Feb 2013
If you set a breakpoint in a function the debugger will stop there and you can inspect variables. You can also step in a variety of ways (step, step in, continue execution, etc).
The example provided in the blog post just seems to be encoding your own custom breakpoint mechanism that is available at runtime. It's not uncommon to use such constructs in a language to enable higher logging levels based on either a file (as in the example) or the setting of an environment variable. You can certainly do this in MATLAB jsut as you would any other programming language that can read the filesystem or check the value of environment variables. What you do when you hit that breakpoint is up to you -- continue execution, log a diagnostic message, output something to the screen, etc.
I see. I'd suggest you add in something that writes to a log that you can check to see how things are progressing without stopping execution.
(just to be clear -- although I am "MathWorks Staff", I'm writing this advice as "myself")
Sean de Wolski on 13 Feb 2013
Edited: Sean de Wolski on 13 Feb 2013
You can use ctrl+c to stop some things but not all. See this solution:
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!