Drawing figure in a for loop

조회 수: 2 (최근 30일)
S. David
S. David 2014년 6월 21일
댓글: Star Strider 2014년 6월 22일
Hello all,
I have a for loop and I want to see the progress of the figure as the loop goes. Basically the code is like this:
SNRdB=0:20;
nErr=zeros(length(SNRdB),1);
for ii=1:length(SNRdB)
...
nErr(ii)=...
figure(1)
semilogy(SNRdB,nErr)
end
However, when I write it this way the figure is halted during the next loop and I cannot see it. How can I see the figure freely while the loop is running?
Thanks
  댓글 수: 7
Star Strider
Star Strider 2014년 6월 21일
Minimising it seems to be the problem.
Geoff Hayes
Geoff Hayes 2014년 6월 21일
Right - and S. is minimizing it because he has other stuff to do and doesn't want to see that figure or have it occupy area on his screen. Only at some point later does S. want to review the figure to check the progress by "retrieving the figure frame from the task bar".

댓글을 달려면 로그인하십시오.

답변 (2개)

Star Strider
Star Strider 2014년 6월 21일
The drawnow function and its friends will probably do what you want. The Example is fun to watch!
  댓글 수: 2
S. David
S. David 2014년 6월 21일
I did this, and it works as long as the update occurs while the figure is not minimized to the task bar.
The problem is that the update process takes too long, and thus I have to minimize the figure to the task bar to do something else. The update will occur randomly while the figure is minimized. So, when I press on the figure in the task bar to see it after the update, again, it is halted and I cannot see it!!
Star Strider
Star Strider 2014년 6월 21일
편집: Star Strider 2014년 6월 21일
Nothing in the UI functions offers a solution, unfortunately.
My only suggestion is to not minimise it to the taskbar but position the figure off to the side, and then click on it when you want to see it. This is my usual strategy, but then I don’t know what’s on your desktop or how it’s organised.
You can also bring it to the foreground by clicking on it on the toolbar even when it’s not minimised. If you don’t minimise it, you may avoid the problem entirely.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2014년 6월 21일
Why are you calling figure(1) at all? Just get rid of it. You can use maxfig (in MATLAB Central) to get the window state and if it's not minimized, call drawnow after you call plot.
  댓글 수: 6
Image Analyst
Image Analyst 2014년 6월 22일
Looks like they took it down. You can try this or try this
Star Strider
Star Strider 2014년 6월 22일

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by