0
votes

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.

1
One key thing allways: check your movie not with widows player or VLC, open it with Quicktime or load it in MATLAB and check the frames. Windows player and VLC use algorithms to relax the workoald they need when visualizing and often they wont show any change when there is. Another way of solving this is saving the movie with repeated frames (5~10 or so)Ander Biguri
@AnderBiguri I would like to try the second solution, but what's mean by saving the movie with repeated frames? Thanks.Kelvin S
It means you need to repeat the matrices saved in FAnder Biguri
@AnderBiguri, another thing I would like to ask is although I have administrator account of my window it seems that I cannot create avi file and get the error message: Error using avi Unexpected Error. Reason: Failed to open file. Error in audiovideo.internal.aviwriter (line 168) aviobj.FileHandle = avi('open',filename); Error in movie2avi (line 63) avimov = audiovideo.internal.aviwriter(filename,varargin{:}); Error in MakeMovie (line 20) movie2avi(F, 'myPeaks.avi', 'compression', 'None');Kelvin S
Update: I added a command "set(gcf,'Renderer','zbuffer');" when I use R2014a and the problem is solved. It is just like using writeVideo in R2015a without that command. Thank you.Kelvin S

1 Answers

1
votes

Have you tried

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

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