How do I display the code line number?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sebastian
el 9 de Mayo de 2016
Comentada: Sebastian
el 13 de Mayo de 2016
Hello! Of all the questions people have asked, noone seem to have been wondering about this. Please correct/redirect me if I'm wrong!
Let's say I have a large amount of unique if-loops that are pretty much similar. Every if-loop has two options where the first is the actual script, and the other one is just a sort of else-prompt that only shows very rarely, or even never.
If I in the else-option want to use disp('This was not what you wanted') and after that tell me where in my code I actually am, like what code-line am I at, how could I do that?
If I get an error from, really whatever, it tells me what function file and what line number I'm at. This I want to be able to call myself. I know I can do it manually easily with something like disp('This was if-loop "Adam", and it wasn't right').
Thanks!
0 comentarios
Respuesta aceptada
Fangjun Jiang
el 9 de Mayo de 2016
I suggest using the warning('msg'). It will tell you the code line number in the Command Window when it happens.
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!