How to output multiple figures?

조회 수: 6 (최근 30일)
toby
toby 2014년 2월 27일
댓글: toby 2014년 2월 28일
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일
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일
Warning: not tested
Replace
saveas(f,'c:\image_i.png')
by
saveas( f, sprintf( 'c:\\image_%i.png', i ) )

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by