Breakpoints in code. Something equivalent to the Stop command in interpreted Basic.

35 vues (au cours des 30 derniers jours)
I'm wanting to put permanent breakpoints in code. Something equivalent to the Stop command in interpreted Basic. As with the Editor's breakpoints, I want the cursor to be at the interruption point. And I want to continue with F5. Any ideas?

Réponse acceptée

Steven Lord
Steven Lord le 6 Mar 2017
Use the keyboard function.
  3 commentaires
Steven Lord
Steven Lord le 6 Mar 2017
If you have the Editor/Debugger preference "Automatically open files when MATLAB reaches a breakpoint" enabled (in the "General Preferences for the Editor/Debugger" section of this documentation page) it will automatically open the file in which the keyboard command is called to the line where it is called.
John
John le 7 Mar 2017
Steven, Thanks for your response. Yes, "Automatically open files when MATLAB reaches a breakpoint" is turned on. Perhaps it wasn't before. I installed ML 2016b this afternoon, and perhaps that default (?) is different than what I had before. I am seeing the curser at the 'keyboard' statement, and perhaps wasn't before. So using 'keyboard' is perhaps the best I can do in ML.
Thanks, also, to Walter.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 6 Mar 2017
Modifié(e) : KSSV le 10 Fév 2021
  8 commentaires
John
John le 24 Nov 2020
Thank you, gentlemen. I'll try the STOP function when I'm next using Matlab.
Ivan Nascimento
Ivan Nascimento le 8 Juil 2021
Modifié(e) : Ivan Nascimento le 8 Juil 2021
Walter's STOP worked perfectly for me but only once I changed str2num to num2str, since dbstop receives a string as argument and ST(2).line is double. It works even when it is called before a comment or blank line (it stops in the next executable line, if it exists). Thank you, Walter!
EDIT. From dbstop help: To resume execution, use dbcont or dbstep. To exit from the debugger, use dbquit.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by