MATLAB: How can i draw a simultaneous animated plot

3d plotsanimationdrawplotproblemsimultaneous

Hello all, this is the first time i write here. I made this plotting and basically is the same plot but in different point of view. I would like to start the "two cycle for" simultaneously, or at least plotting the result simultaneously. I saw there is another question like this but i can't understand the answer.
%%defining variables
np=length(xT);
x=flip(xT);
y=yT;
z=zT;
%%a kind of option menú
on=1;
off=0;
enable_plot_dot_3d=off;
enable_plot_line_3d=on;
enable_plot_vertical=on;
subplot (1,2,1)
%%starting plotting first point

plot3(x(1),y(1),z(1))
view([180 90]) %set azimuth and elevation of plot

xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
grid
hold on
%%starting add the others point according of menú

for i=2:np-1
% line (i make a mistake with variable name)

if(enable_plot_dot_3d) %un po inutile per me

plot3(x(i:i+1),y(i:i+1),z(i:i+1),'-r','linewidth',2)
end
% dots

if(enable_plot_line_3d)
plot3(x(i+1),y(i+1),z(i+1),'o','markerfacecolor','r')
end
% height marker

if(enable_plot_vertical)
plot3([x(i+1) x(i+1)],[y(i+1) y(i+1)],[0 z(i+1)],'b')
end
% plot speedy

pause(sec+0.05)
end
subplot (1,2,2)
%%starting plotting first point
plot3(x(1),y(1),z(1))
view([180 0]) %set azimuth and elevation of plot
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
grid
hold on
%%starting add the others point according of menú
for i=2:np-1
% line (i make a mistake with variable name)
if(enable_plot_dot_3d) %un po inutile per me
plot3(x(i:i+1),y(i:i+1),z(i:i+1),'-r','linewidth',2)
end
% dots
if(enable_plot_line_3d)
plot3(x(i+1),y(i+1),z(i+1),'o','markerfacecolor','r')
end
% height marker
if(enable_plot_vertical)
plot3([x(i+1) x(i+1)],[y(i+1) y(i+1)],[0 z(i+1)],'b')
end
% plot speedy
pause(sec+0.05)
end
%%clear temporary variables
clear enable_plot_vertical enable_plot_dot_3d...
enable_plot_line_3d i np on off

Best Answer

thanks a lot Mike for the answer i made it by using
set(h,'visible','off')
set(h,'visible','on');
where 'h' is the plot variable
%defining variables
np=length(xT);
x=flip(xT);
y=yT;
z=zT;
h=figure();
set(h,'visible','off'); %ths prevent figure to show data
subplot (1,2,1)
% starting plotting first point plot1
plot3(x(1),y(1),z(1))
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
grid
view([180 90])
hold on
%starting plotting first point plot2
subplot (1,2,2)
plot3(x(1),y(1),z(1))
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
grid
view([180 0])
hold on
%starting add the others point
for i=2:np-1
subplot (1,2,1)
plot3(x(i:i+1),y(i:i+1),z(i:i+1),'-r','linewidth',2)
plot3(x(i+1),y(i+1),z(i+1),'o','markerfacecolor','r')
plot3([x(i+1) x(i+1)],[y(i+1) y(i+1)],[0 z(i+1)],'b')
subplot (1,2,2)
plot3(x(i:i+1),y(i:i+1),z(i:i+1),'-r','linewidth',2)
plot3(x(i+1),y(i+1),z(i+1),'o','markerfacecolor','r')
plot3([x(i+1) x(i+1)],[y(i+1) y(i+1)],[0 z(i+1)],'b')
pause(sec+0.05) %just a pause to see data better
set(h,'visible','on') %this show all the data again
end
%%clear temporary variables
clear enable_plot_vertical enable_plot_dot_3d...
enable_plot_line_3d i np on off
Related Question