catch.ME returns incorrect line number for error
이전 댓글 표시
hi team
I have a script to download stock data and then do some analysis. The entire script is working fine except one little issue. I have try-catch function in my script to help me continur with stock analysis when error occurs. However when I use fprintf(ME.stack(1).line) to tell me the error location (line number) it return completely incorrect line numbers. My script has the following:
%% - to break the script in blocks for ease of use
... - to break codes in multiple lines for better readability
multiple For, If loops.
Due to sensitive info I have removed my codes but have created a structure of my script and attached here. If anyone can please help me understand why catch.ME returns incorrect line number it would be great.
Within try catch block - My codes has only two lines within try and catch block that needs try and catch (i.e., try, catch error and skip that iteration), other codes within the block just need to get skipped when error occurs. Is there a way in try catch function that we can tell what lines to apply try and catch and for the rest of the codes it throws an error and stop?
Summary - Try catch is working fine, doing what it needs to do except returning correct line number where error occured. I need help with this please.
My code has Me.stack(1).line, I noticed on matlab Q&A forum someone mentioning using Me.stack(end).line. Does this make any difference?
Regards
Amit
댓글 수: 2
Walter Roberson
2025년 2월 23일
Is it possible that your script is LiveScript ?
Amit Patel
2025년 2월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!