Effacer les filtres
Effacer les filtres

Export plot as 600dpi png and with variables in the file name

8 vues (au cours des 30 derniers jours)
Miraboreasu
Miraboreasu le 18 Déc 2022
Modifié(e) : Jan le 18 Déc 2022
iter = 1;
for i=1:10
t =1:1:1000;
p =t*i;
figure
plot(t,p,'Color', 'b','LineWidth',2)
hold on
set(gca,'FontWeight','bold','FontSize',18)
%Works if
%print(gcf,'p.png','-dpng','-r600');
print(gcf,'p%s.png',iter,'-dpng','-r600');
end
How to export figure with a name variable in the filename and 600dpi. Thanks!

Réponse acceptée

Jan
Jan le 18 Déc 2022
Modifié(e) : Jan le 18 Déc 2022
print(gcf, sprintf('p%d.png', iter), '-dpng', '-r600');
% [EDITED], %s -> %d
  1 commentaire
Miraboreasu
Miraboreasu le 18 Déc 2022
Modifié(e) : Miraboreasu le 18 Déc 2022
Thanks, but Error using matlab.graphics.internal.name Unable to create output file '.\p.png', Invalid argument.
fixed by
print(gcf, sprintf('p%d.png', iter), '-dpng', '-r600');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by