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?!
2 Answers
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

- 106
- 1
-
??? 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
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.

- 1,234
- 13
- 24