MATLAB Answers

AA
0

saving all figures as jpeg file on harddrive

Asked by AA
on 23 Apr 2018
Latest activity Edited by Benni
on 23 Apr 2018
Hi, i got a loop and it creates many figures (figure 1, figure 2 and so on). I want to save all as jpeg file on my harddrive. Any ideas?

  0 Comments

Sign in to comment.

1 Answer

Answer by Benni
on 23 Apr 2018
Edited by Benni
on 23 Apr 2018
 Accepted Answer

Collect all the figure handles in a figure handle array, e.g. f(ii) = figure; and then work with arrayfun on the saveas command.
MWE:
clearvars, close all, clc
for ii = 1:10
f(ii) = figure('name',sprintf('fig_%.2d',ii));
plot(rand(5,1),rand(5,1))
end
arrayfun(@(x) saveas(x,x.Name,'jpeg'),f)

  0 Comments

Sign in to comment.