How to output multiple figures?

As the code below, I generate a picture in each loop. How do I use saveas() to store every image in a given folder with the name 'image_i.png'(where i is a variable)? So I get ten images named image_1 to image_10.
for i = 1:10
f = figure();
hold on;
plot(A);
plot(B);
text('');
saveas(f,'c:\image_i.png')
end

 採用された回答

Chandrasekhar
Chandrasekhar 2014 年 2 月 27 日

0 投票

for i = 1:10
f = figure();
hold on;
plot(A);
plot(B);
text('');
fileName = ['image_' num2str(i) '.png'];
saveas(f,fileName);
end

その他の回答 (1 件)

per isakson
per isakson 2014 年 2 月 27 日
編集済み: per isakson 2014 年 2 月 27 日

0 投票

Warning: not tested
Replace
saveas(f,'c:\image_i.png')
by
saveas( f, sprintf( 'c:\\image_%i.png', i ) )

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

質問済み:

2014 年 2 月 27 日

コメント済み:

2014 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by