MATLAB: How to output multiple figures

automatically generate picturesimagepicture storeplot

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

Best Answer

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