MATLAB Answers

0

creating an animated video by rotating a surface plot

Asked by Optical_Stress on 27 Apr 2018
Latest activity Commented on by Sky Nelson-Isaacs on 6 Nov 2019 at 1:49
I'm struggling to get a consistent animation that has fixed axis when rotating my surface plot. Two of the problems i have faced are:
1) the data size of my surfplot changes as the rotation angle changes. 2) the color of the surface plot is not retained when i store the data in a structure. 3) So far I have compiled this:
number_of_frames = 360;
n=1;
for i = 1:10:number_of_frames
hSurface = surf(velocityimg);
grid off
rotate(hSurface,[0 0 1],i);
newdata(n).x = hSurface.XData;
newdata(n).y = hSurface.YData;
newdata(n).z = hSurface.ZData;
surf(newdata(n).x,newdata(n).y,newdata(n).z);
grid off
hAxes = gca;
hAxes.XRuler.Axle.LineStyle = 'none';
axis off
axis vis3d
colormap(jet)
g(n) = getframe(gcf);
g(n) = frame2im(g(n));
n=n+1;
end
%%make video
v = VideoWriter('rotating.avi');
v.FrameRate = 10;
v.Quality = 65;
open(v);
for i =1:length(g)
frame = g(i).cdata;
writeVideo(v,frame);
end
close(v);
winopen('rotating.avi');

  1 Comment

I have the same issue. How do I keep the axes consistent as I rotate the frame and take snapshots?

Sign in to comment.

0 Answers