Kelvin S
Kelvin S

Reputation: 351

MATLAB movie2avi cannot made video

I am trying to test the function movie2avi using simple codes in R2014a as follows:

clear; close all;
figure;
Z = peaks;
surf(Z);
axis tight manual;
ax = gca;
ax.NextPlot = 'replaceChildren';

loops = 40;
F(loops) = struct('cdata',[],'colormap',[]);
for j = 1:loops
    X = sin(j*pi/10)*Z;
    surf(X,Z);
    drawnow;
    F(j) = getframe(gcf);
end

movie(F);

movie2avi(F, 'myPeaks.avi', 'compression', 'None');

It seems the movie(F) works well but the avi file created contains the toolbar and background instead of just showing the graph. Also the avi file just show stationary picture as follow:

enter image description here

Using quicktime to open it would produce same result:

https://www.dropbox.com/s/fd8vw7jvll5xkpw/b.png?dl=0

There is also a warning: Warning: Struct field assignment overwrites a value with class "double". See MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning, for details.

Please help. Thanks.

Upvotes: 0

Views: 226

Answers (1)

kkuilla
kkuilla

Reputation: 2256

Have you tried

F(j) = getframe(gca); %// Gets the current axis 

This will capture the axis rather than the entire figure window.

Upvotes: 1

Related Questions