I’m debugging a matlab script that takes ~10 minutes to run. Towards the end of the script I do some i/o and simple calculations with my results, and I keep running into errors. Is there a way to start matlab from a certain sport in a script after it exits with an error–the data is still in the workspace so I could just comment out all of the code up until the error point, but I’m wondering if anyone knows a better way to go about doing this without rerunning the entire script (the ultra-lazy/inefficient way)?
Thanks,
Colorado
Yes, use
dbstop. Typedbstop if errorand then run your script. The minute it hits an error, it will create a breakpoint there and you’re in the workspace of the script — which means you can debug the error, save data ; anything you want! Here’s a snippet from the documentation fordbstop if error— there are other ways to dodbstop, so do check it out: