Step by frame by frame in Matlab

I want a plot

shape that changes over time in matlab. Then I want you to be able to walk through the graphs in stages. How can I achieve this?
I created movie

but there seems to be no way to do this easily. I've seen this somewhere before, so I know there is a solution.

+3


source to share


1 answer


If your movie was created with "getframe", you can use the following code:

This creates an example movie:

Z = peaks; surf(Z); 
axis tight
set(gca,'nextplot','replacechildren');
% Record the movie
for j = 1:20 
    surf(sin(2*pi*j/20)*Z,Z)
    F(j) = getframe;
end
% Play the movie
figure(1);clf;
movie(F)

      



This checks every frame, one at a time:

for j=1:20
    [X,map] = frame2im(F(j));
    figure(2);clf;
    image(X);
    pause; 
end

      

Pressing the spacebar will release "pause" so you can independently explore each frame.

+2


source







All Articles