필터 지우기
필터 지우기

Problem with axes handle.

조회 수: 3 (최근 30일)
Siddharth
Siddharth 2013년 6월 6일
I made a gui with a progressing plot in which i used a for loop. I want the plot to be in the axes ( with handle axes2 ) area which i defined in the gui. this is a part of my program:
for i=1:numel(B1)
axes(handles.axes2);
plot(B1(1:i),B2(1:i),B1(i),B2(i),'*r');
axis([min(B1) max(B1) min(B2) max(B2)]);
end
but in this the loop only runs once and then i get an error saying
'Error using axes Invalid object handle'.
please suggest me how to rectify it.
Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 6월 6일
When you do not have "hold on" (or its internal equivalent) in effect, plot() does the equivalent of clf() [clear figure] which results in the axes being deleted as the axes is underneath the figure.
Are you trying to draw multiple plots in the same axes, beside each other? Or multiple plots that are visually on top of each other? Or are you wanting to draw one at a time to "animate" the plots? If you are animating, have a look at the drawnow() command.
  댓글 수: 2
Siddharth
Siddharth 2013년 6월 6일
i am trying to animate it by plotting one over another through the loop. this works perfectly if i use the figure handle of the gui for the plot but gives an error if i use the axes handle.
Walter Roberson
Walter Roberson 2013년 6월 6일
After the first axes() call, add
cla();
hold on
Then after the second axes() call, add
drawnow()
You might also want to add a pause() call.

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

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by