problem in using Eval with saveas function

4 vues (au cours des 30 derniers jours)
minoo
minoo le 25 Avr 2011
[EDIT: Thu May 12 23:04:08 UTC 2011 Duplicate Removed - MKF]
Hi everybody,
I'm trying to use eval with "saveas" function to save my figures. I have a loop and the name of figures will be generated according to counter. in the below code my counter is "i" and the name of figure in the first iteration will be: IC1_1_1
eval(['saveas(gfc,IC1_' num2str(i)'_1.jpg') ')']);
and the result of above code will be: saveas(gcf,IC1_1_1.jpg)...which is wrong for saveas function because in saveas function I must use single quotation for the filename, that means for saving my first figure, the result of eval should be: saveas(gcf,'IC1_1_1.jpg').
could you help me to handle this problem?

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Avr 2011
Skip the eval()
saveas(gcf, ['IC1_', num2str(i), '_1.jpg']);
or
saveas(gcf, sprintf('IC1_%d_1.jpg', i));
  1 commentaire
minoo
minoo le 25 Avr 2011
yes it works, thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by