필터 지우기
필터 지우기

I am doing a GUI which plots a cube when the user enters the dimension of the cube. But If i keep entering new dimensions, the old cube still stays at the display? Is there any way to delete the previous figure every time when new data is entered?

조회 수: 3 (최근 30일)
I am doing a GUI which plots a cube when the user enters the dimension of the cube. But If i keep entering new dimensions, the old cube still stays at the display? Is there any way to delete the previous figure every time when new data is entered?

채택된 답변

Star Strider
Star Strider 2014년 7월 7일
Without seeing your code I don’t know what you’ve already done. Perhaps the drawnow function will do what you want. (There are links to its friends at the end of that page and in the menu to the left of the text in the online documentation page.)
  댓글 수: 2
matlablearner
matlablearner 2014년 7월 7일
편집: Star Strider 2014년 7월 7일
This is the sub function which gets executed when I enter the dimension of the cube(In the GUI).
case 'cube'
a = str2double(get(handles.cubedimension,'string'));
fm = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8];
vm = [0 0 0; a 0 0; a a 0; 0 a 0; 0 0 a; a 0 a; a a a; 0 a a];
patch('Vertices',vm,'Faces',fm, 'FaceVertexCData',hsv(6),'FaceColor','flat');
%set default view
az = wrapTo360(-37.5); el = 30; %limits for az 0...360 for el 0...90
view(handles.axes1,[az el]);
set(handles.Horizontalslider,'value',az/360);
set(handles.Verticalslider,'value',el/90);
axis([0 a*1.25 0 a*1.25 0 a*1.25]);
Where should I include the drawnow ? Thanks a lot for your quick response
Star Strider
Star Strider 2014년 7월 7일
Probably just after the patch call. See the documentation for details and Examples.
You might also need to use the refreshdata function.
You will likely have to experiment to get the result you want.

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

추가 답변 (1개)

Ben11
Ben11 2014년 7월 7일
Using drawnow would refresh the plot and get rid of the old one; that might do the trick

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by