2

I have some calculation with matrices and have set my loop to run for (let's say) 50 times. I also assigned a color to each value so I can get a picture in the end of these matrices based on their values. What I don't know is - how to make an animation from this multiple images I get in each turn. Is it possible?!

kojikurac
  • 205
  • 2
  • 4
  • 11
  • Have a look at this question: http://stackoverflow.com/questions/2716837/animation-in-matlab – Alex Apr 17 '11 at 23:33

2 Answers2

0

The following code is what I have used previously to produce an .avi file

n = 15;
p = randperm(n);

figure('Color','white');
fcount = 0;
for k = 1:n-1
    % produce the plot
    [idx,idx] = min(p(k:n));
    p(idx+k-1) = p(k);
    p(k) = k;
    plot(p,'*')
    % Make sure plot updates before we capture the contents
    pause(0.1)
    F(k) = getframe(gcf); %#ok 
end
movie2avi(F,'so1.avi','fps',2,'quality',100);

However, there seems to be some issues with the avi codec now for use with Windows XP, for example see this thread. http://www.mathworks.com/matlabcentral/newsreader/view_thread/271172

I had the same problem; the avi file produced with the default Indeo codec would not run in Windows Media Player. Using a different codec, such as

movie2avi(F,'so1.avi','fps',2,'quality',100,'compression','Cinepak');

solved the problem. You may need to experiment to find a working combination.

Hth, Darren

  • ??? The following error occurred converting from struct to double: Error using ==> double Conversion to double from struct is not possible. Error in ==> filmic at 14 F(k) = getframe(gcf); %#ok – kojikurac Apr 27 '11 at 09:50
-1

I'm not sure what you're trying to do. One option is to use the MS-GIF animator, although 50 images is a bit much. See http://en.wikipedia.org/wiki/Microsoft_GIF_Animator for info. Considering the number of images, you might want to create a powerpoint document.

Dave
  • 1,234
  • 13
  • 24