How can I "watch" variables using the MATLAB Debugger?
    38 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    MathWorks Support Team
    
 il 18 Lug 2011
  
    
    
    
    
    Modificato: MathWorks Support Team
    
 il 10 Lug 2020
            I would like to set "watches" on variables while using the MATLAB Debugger. In particular, I would like to configure the debugger to break when the variable reaches a certain value or exceeds a certain range.
Risposta accettata
  MathWorks Support Team
    
 il 10 Lug 2020
        
      Modificato: MathWorks Support Team
    
 il 10 Lug 2020
  
      In order to "watch" a variable, you can set a conditional breakpoint to stop when a certain condition is met. You can select a conditional break point interactively from the editor tab in MATLAB R2012b or newer, or through the command line.
For example, to stop in debug mode when ii is equal to 25, in the file "watched.m", which consists of the following:
for ii = 1:100
      disp(ii)
end
You could run:
dbstop in watched at 2 if (ii == 25)
For more information, please see the documentation for dbstop:
0 Commenti
Più risposte (1)
  Marshall
      
 il 28 Apr 2014
        You can set conditional breakpoints to stop when a variable meets some condition that you specify: Where breakpoints are shown right click and select "set conditional breakpoint" or right click on an existing breakpoint and choose "set/modify condition". Then type an expression that will be evaluated to trigger the breakpoint, e.g. a>100.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Debugging and Analysis in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!