continue for-loop despite matlab error
조회 수: 7 (최근 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!