clearing a figure

8 visualizaciones (últimos 30 días)
saloni singhal
saloni singhal el 9 de Jun. de 2012
Editada: Jan el 8 de Ag. de 2021
sir,
I want to erase the previous figure before the next figure.for this i have used erase mode but its not still i am getting previous figure in the graph so i tried to use clf but it provide flickering.. so , can anyone help me in this and tell me why erasemode not working or anyother method to remove previous image
thank you
x(5) = 6;y(5) = 3 ;z(5) = 6;
x(4) = 6;y(4) = 0;z(4) = 6;
x(3) = 6;y(3) = -3;z(3) = 6;
x(6) = 0;y(6) = 3;z(6) = 0;
x(1) = 0;y(1) = 0;z(1) = 0;
x(2) = 0;y(2) = -3;z(2) = 0;
x = x';
y = y';
z = z';
f = patch(x,y,z,'Y');
set(f,'FaceLighting','phong','EdgeLighting','phong');
set(f,'EraseMode','normal');
camlight;
grid on;
xlim([0,6]);
ylim([-3,3]);
zlim([0,6]);
p = -1.5*pi;
q = -pi/2;
r = 0;
t = -37.5;
pause(1);
clf;
for i = 1:1:5
pause(0.1);
s = 5;
p = p + (0.0175*s);
q = q + (0.0175*s);
x(1)=0; y(1) =0;z(1) =0;
x(6) = 3*cos(p); y(6) = 3*sin(p); z(6) = 0;
x(2) = 3*cos(q); y(2) = 3*sin(q); z(2) = 0;
x(5) = 6+3*cos(p); y(5) = 3*sin(p); z(5) = 6;
x(3) = 6+3*cos(q); y(3) = 3*sin(q); z(3) = 6;
x(4) = 6; y(4) =0;z(4) = 6;
u = patch(x,y,z,'Y');
set(u,'FaceLighting','phong','EdgeLighting','phong');
set(u,'EraseMode','normal');
view(t,30);
camlight
grid on;
xlim([-4,10]);
ylim([-4,4]);
zlim([0,6]);
pause(1);
drawnow;
clf;
end

Respuestas (3)

Gbola
Gbola el 9 de Jun. de 2012
delete(handles.figure1); Where figure1 is the name given to the figure i question.

Walter Roberson
Walter Roberson el 9 de Jun. de 2012
The flickering is because you have a pause() at the beginning of the loop; on the second and other iterations of the loop, that pause() is happening just after you clf(). A pause() does not just delay: it also triggers a screen update.
The pause(1) at the end of your loop is triggering a screen update, so the drawnow() after it and before the clf() is not doing anything useful there. drawnow() is generally a good idea, but it happens that pause() also draws.
  1 comentario
Bandar
Bandar el 6 de Ag. de 2021
What is the solution then in this case? I need pause and clf together.

Iniciar sesión para comentar.


Jan
Jan el 6 de Ag. de 2021
Editada: Jan el 8 de Ag. de 2021
A simplified version of your code without clf and flickering:
x = [0; 0; 6; 6; 6; 0];
y = [0; -3; -3; 0; 3; 3];
z = [0; 0; 6; 6; 6; 0];
f = patch(x,y,z,'Y');
set(f,'FaceLighting','phong','EdgeLighting','phong');
camlight;
grid on;
xlim([0,6]);
ylim([-3,3]);
zlim([0,6]);
p = -1.5 * pi;
q = -pi / 2;
t = -37.5;
s = 5;
pause(1);
view(t, 30);
xlim([-4,10]);
ylim([-4,4]);
for i = 1:5
p = p + (0.0175 * s);
q = q + (0.0175 * s);
x = [0; 3*cos(q); 6+3*cos(q); 6; 6+3*cos(p); 3*cos(p)];
y = [0; 3*sin(q); 3*sin(q); 0; 3*sin(p); 3*sin(p)];
z = [0; 0; 6; 6; 6; 0];
set(f, 'XData', x, 'YData', y, 'ZData', z);
pause(1);
end

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by