catch.ME returns incorrect line number for error
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 23 Fév 2025
Is it possible that your script is LiveScript ?
Amit Patel
le 23 Fév 2025
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming Utilities dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!