Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
John, Fabian
cosa-tools-matlab
Commits
4fdabef2
Commit
4fdabef2
authored
Jun 17, 2021
by
John, Fabian
Browse files
added functionality to save figure plots as gif easy
parent
c381e987
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/save_as_gif.m
0 → 100644
View file @
4fdabef2
function
fig_handle
=
save_as_gif
(
filename
,
fig_handle
,
first_run
)
%SAVE_AS_GIF saving given figure in fig_handle to gif animated file
% filename: target file (Example: 'test.gif'
% fig_handle: figure, that should been saved (fig_handle = figure(1))
% first_run: indicate, if the current image is the first, that will been
% saved to the animated gif (1 if first)
figure
(
fig_handle
);
if
first_run
==
1
axis
tight
manual
% this ensures that getframe() returns a consistent size
end
drawnow
;
frame
=
getframe
(
fig_handle
);
im
=
frame2im
(
frame
);
[
imind
,
cm
]
=
rgb2ind
(
im
,
256
);
%Write to the GIF File
if
first_run
==
1
imwrite
(
imind
,
cm
,
filename
,
'gif'
,
'Loopcount'
,
inf
);
else
imwrite
(
imind
,
cm
,
filename
,
'gif'
,
'WriteMode'
,
'append'
);
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment