简体   繁体   中英

How do I create a movie in matlab using a matrix

I have a matrix (h) that I have formed in matlab that comes out as a 65x11, I'm looking to create a movie that displays plots of each column of the matrix. Eg 65 frames

try this:

for i = 1:size(h,1)
    bar(h(i,:))
    ani(i) = getframe;
end
movie(ani)

if you want to create an animated .gif file, try

filename='myanimation.gif';

for i = 1:size(h,1)
    bar(h(i,:))
    ani = getframe;
    im=frame2im(ani);
    [imind,cm] = rgb2ind(im,256);
    if i == 1;
        imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
    else
        imwrite(imind,cm,filename,'gif','WriteMode','append');
    end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM