Using try/catch in a While Loop to Repeatedly Execute MATLAB Code
You may be familiar with using try/catch statements to make your code robust to errors. Matt covered them in a series of posts. A try/catch statement will catch one occurrence of an error in the try section and then continue to the catch. But what if you want to keep trying the same piece of code until it works? This video shows how to do this by inserting the try/catch statement in a while loop.
You can skip the section from 6:45 to 9:20, labeled in the table of contents “Breakpoint Not Working” to “Continue Stepping Through tryfunc” where I struggle to understand why something is not working. I eventually explain what is going on @15:45, labeled “Explanation of Breakpoint not working” in the table of contents.
Play the video in full screen mode for a better viewing experience.
- Category:
- Format: Video
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.