Breakpoints required for code to work correctly?
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
Fangjun Jiang
2011년 8월 10일
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
Fangjun Jiang
2011년 8월 10일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!