I want to save multiple figures to the same folder, with the name of figure_1, figure_2, etc.
Here is the code: x = 1:5;
y = [1,1,1,1,1]
z = [2,2,2,2,2]
a = [3,3,3,3,3]
b = [4,4,4,4,4]
c = [5,5,5,5,5]
figure;
plot(x,y)
figure;
plot(x,z)
figure;
plot(x,a)
figure;
plot(x,b)
figure;
plot(x,c)

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 4 月 23 日

1 投票

figure;
h(1)=plot(x,y)
figure;
h(2)=plot(x,z)
figure;
h(3)=plot(x,a)
figure;
h(4)=plot(x,b)
figure;
h(5)=plot(x,c)
for k=1:5
saveas(h(k),sprintf('figure_%d.jpg',k))
end

3 件のコメント

Image Analyst
Image Analyst 2013 年 4 月 24 日
The above code saves to the current folder. To save it to a specific folder, use fullfile, as shown below:
baseFileName = sprintf('figure_%d.jpg',k);
% Specify some particular, specific folder:
fullFileName = fullfile('D:\myPlots', baseFileName);
figure(k); % Activate the figure again.
export_fig(fullFileName); % Using export_fig instead of saveas.
Mohammad Bhat
Mohammad Bhat 2018 年 2 月 23 日
Undefined function or variable 'export_fig'. Matlab 2016

サインインしてコメントする。

その他の回答 (1 件)

venkata reddy kopparthi
venkata reddy kopparthi 2018 年 7 月 12 日
編集済み: venkata reddy kopparthi 2018 年 7 月 12 日

0 投票

  • we can save current open figure by saveas library
  • saveas(gcf,'<path>\figure_name.jpg');

1 件のコメント

Tanziha Mahjabin
Tanziha Mahjabin 2020 年 2 月 17 日
Hi,
i have already saved figures in a folder. how can i make a gif in matlab combining all of them?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Printing and Saving についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by