Breakpoints required for code to work correctly?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have inherited a piece of code (m-file function) that works fine on its own, but when I used it inside other m-files it only works if I put a breakpoint in it. The section that doesn't seem to work without breakpointing is:
% If task completed, close figure and clear vars, then exit
if percentdone == 100 % Task completed
delete(progfig) % Close progress bar
%change the close request function back to normal
%set(progfig,'CloseRequestFcn','closereq');
% Clear persistent vars
clear progfig progpatch starttime lastupdate firstIteration
return
end
Can anyone help me understand why a breakpoint should change the behavior of this code? Specifically, the line 'delete(progfig) does not seem to execute unless there is a breakpoint somewhere within the if statement.
Thanks in advance, Sean
0 Commenti
Risposta accettata
Fangjun Jiang
il 10 Ago 2011
What do you mean "doesn't seem to work"? Any error messages? If you don't have break point, is it that the progress bar didn't close? Situation like that might happen. You might want to add a line "pause(0.1);" or "drawnow;" after the delete(progfig) line.
2 Commenti
Fangjun Jiang
il 10 Ago 2011
You might have some busy operation after the chunk of the code you posted. It's like the computer is too busy to refresh the graphics. I think the same thing happens to the Windows OS too. Help drawnow might give you some idea. I don't know the details. It happened to me too. That's why I could guess your problem.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!