continue for-loop despite matlab error
1 次查看(过去 30 天)
显示 更早的评论
I want to process a number of images for data analysis. If one of the images causes a matlab error, I want the program to display a message but to continue with the analysis of the following images. So it would need to continue with the next iteration of a for loop. Is this possible and how would I do this?
Thanks, Christine
0 个评论
采纳的回答
Daniel Shub
2012-4-19
You could do something like
for ii = 1:n
try
% your code
catch ME
warning('Something happened');
end
end
0 个评论
更多回答(1 个)
Christine
2012-4-19
1 个评论
Daniel Shub
2012-4-19
In this case you do not need to catch the exception object (ME). You might want to check ME to make sure it was because the there was a mistake in the picture number and not some other error.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!