Plotting animated trajectories using plot3.

9 views (last 30 days)
Mandar
Mandar on 13 Aug 2013
Hello,
I have a vector array xt = [x y z] and I want to plot3 an animated trajectory. The following code does not work...as it does not retain the traversed trajectory in spite of the 'hold on' and only shows the current position. I tried putting the 'hold on' for the figure(1) as well as outside the 'for' loop.
if true
% code
for i=1:speedup:length(xt)
pause(0.00005);
plot3(xt(i,1), xt(i,2), xt(i,3),'r'); % Plotting trajectory
hold on;
***I have a hgtransform object being translated and rotated here***
end
end
This code works if I use plot3(xt(i,1), xt(i,2), xt(i,3),'*'); with '*' as the print character but it messes up the zoomed out view.
So I have to make the following modification...
if true
% code
for i=1:speedup:length(xt)
pause(0.00005);
plot3(xtdot(1:i,1), xtdot(1:i,2), xtdot(1:i,3),'r'); % Plotting trajectory
hold on;
***I have a hgtransform object being translated and rotated here***
end
end
Even though this works, I would like to know if there is a way to hold the plot3 without any print character.
Thanks in advance.
Regards Mandar

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!