skipping errors in a script
이전 댓글 표시
Hi, I have a script which consists of several functions:
functionA
functionB
functionC
Sometimes I get this error:
Index exceeds matrix dimensions.
Error in functionB (line 44) golrowA = cellContentsA((LA):(LA+120), :);
The question is how can I skip this error so that functionC gets executed because if the error occurs whilst running function B then the entire script stops and then the remaining functionC does not run.
thanks
채택된 답변
추가 답변 (1개)
Although the best solution is to figure out why you are getting those error messages, and fix the problem at the source. Because just skipping over errors is a great way to lose control of what the code is actually doing. Instead, dig into your code, find out why that line gets an index over the size of its array, create a special case to break out of the loop or whatever is a reasonable way to avoid this case. Then your code will be more robust, and it will not hide any future errors from you.
Don't just paste some wallpaper over the cracks in the wall, find out what the problem is and fix it.
카테고리
도움말 센터 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!