Problem with AVI - 3D point animation
10 views (last 30 days)
Show older comments
I am trying to create an animation of target and UAV in 3D plot in MATLAB and the following is a part of the code responsible for the animation. x_t, y_t, h_t are the coordinates of the target and x_a,y_a,h_uav are those of the UAV.
figure(1);
set(gcf,'Renderer','OpenGL');
h = plot3(x_t(1),y_t(1),h_t(1),'o','MarkerSize',7,'MarkerFaceColor','b');
hold on
h1 = plot3(x_a(1),y_a(1),h_uav(1),'o','MarkerSize',7,'MarkerFaceColor','r');
set(h,'EraseMode','normal');
set(h1,'EraseMode','normal');
i = 1;
while i<=length(x_t)
set(h,'XData',x_t(i),'YData',y_t(i),'ZData',h_t(i));
hold on
set(h1,'XData',x_a(i),'YData',y_a(i),'ZData',h_uav(i));
axis([0 1500 0 1500]);
drawnow;
M(i) = getframe;
i = i+1;
end
movie2avi(M, 'trial.avi', 'compression', 'none');
The animation seems to a bit jerky. Any tips to improve that? Also you can find that I create an AVI file in the last line of the snippet above. When I open the avi file only the first frame of the animation is displayed for the entire time. What is wrong with that?
0 Comments
Answers (0)
See Also
Categories
Find more on Animation 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!