creating an animated video by rotating a surface plot

37 visualizzazioni (ultimi 30 giorni)
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 Commento
Sky Nelson-Isaacs
Sky Nelson-Isaacs il 6 Nov 2019
I have the same issue. How do I keep the axes consistent as I rotate the frame and take snapshots?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by