For Programmers: Free Programming Magazines  


Home > Archive > Matlab > March 2007 > Re: problem with









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: problem with
Scott

2007-03-30, 7:11 pm

Alex Shvartser wrote:
>
>
> Hi,
>
> I am having an odd problem with generating a movie. I have the
> following code:
>
> figure
> colormap('hot')
> set(gca,'nextplot','replacechildren');
> for i=1:numOfDates-1
> pcolor(triu(Corr_matricies(:,:,i)))
> title(dates{i})
> caxis([-1 1]),colorbar('EastOutside')
> F(i) = getframe(gcf);
> end
> fps = 2;
> figure
> axis off
> movie(gcf,F,1,fps,[0 0 0 0])
>
> This code basically creates a bunch of frames, and plays a movie of
> those frames.
>
> When the movie command is executed, about halfway through (around
> frame 25), I get the following error message:
>
> ??? Error using ==> movie
> Could not create movie frame
>
> I can't figure out why this is happening... When the frames are
> "recorded", they are recorded all the way through, and there are no
> problems. But when the movie is played back, I get that error.
>
> Any ideas? Thanks so much!


Alex, do you want a matlab movie or a proper .avi or .mpg file? The
movie command is troublesome. I usually do something like this:

% Movie Demonstration

% create some image data
[X Y Z] = sphere(25);
sz = size(Z);
C = rand(sz(1),sz(2),3);

% stitch data to wrap color around sphere
C(:,end,:) = C(:,1,:);

% render an image
hf = figure('Position', [100, 100,...
600, 400],...
'Renderer','OpenGL','color',[0 0 0]);
sp = surf(X,Y,Z,C,'FaceColor','interp',...
'FaceLighting','phong');
material shiny
axis off vis3d
cl = camlight('right');
camzoom(1.5)
set(sp,'edgecolor','none');
drawnow

% setup the rotation vector for the movie
view_vect_yaw = [-180:3:180];
sz_vect = size(view_vect_yaw);

% "lights, camera, action!"
for f = 1:sz_vect(2)
% set the view, reset light position and render
view([view_vect_yaw(f) 15]);
camlight(cl,'right')
drawnow
% grab a frame
m(f) = getframe(gcf);
end
% % format frames as mpeg and write to file
mpgwrite(m,C,'my_movie.mpg',...
[1, 0, 1, 0, 10, 1, 1, 1]);
% end of code

This requires mpgwrite.dll which is available in the FEX.

Scott
Alex

2007-03-30, 7:11 pm

Scott,

Thanks a lot. Actually, I did end up just forgetting about the movie
function and just using movie2avi, which did not cause the same
problem.

But I like your code a lot more! Thanks very much.

Alex
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com