How to output multiple figures?

3 vues (au cours des 30 derniers jours)
toby
toby le 27 Fév 2014
Commenté : toby le 28 Fév 2014
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

Réponse acceptée

Chandrasekhar
Chandrasekhar le 27 Fév 2014
for i = 1:10
f = figure();
hold on;
plot(A);
plot(B);
text('');
fileName = ['image_' num2str(i) '.png'];
saveas(f,fileName);
end
  1 commentaire
toby
toby le 28 Fév 2014
Thanks

Connectez-vous pour commenter.

Plus de réponses (1)

per isakson
per isakson le 27 Fév 2014
Modifié(e) : per isakson le 27 Fév 2014
Warning: not tested
Replace
saveas(f,'c:\image_i.png')
by
saveas( f, sprintf( 'c:\\image_%i.png', i ) )

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by