Using try/catch in a While Loop to Repeatedly Execute MATLAB Code
(Originally posted on Stuart's MATLAB Videos blog.)
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.
Recorded: 28 Jun 2016
Featured Product
MATLAB
Up Next:
Related Videos:
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)