Skip to content

Instantly share code, notes, and snippets.

@guillego
Created February 13, 2018 11:47
Show Gist options
  • Save guillego/340f75161c29932d92d554abeeb0c569 to your computer and use it in GitHub Desktop.
Save guillego/340f75161c29932d92d554abeeb0c569 to your computer and use it in GitHub Desktop.
Matlab save to gif
% This runs within the for loop that iterates between stages of image
% GIF
drawnow
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if this_pulse == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment