How can I specify a dynamic string variable as filename in the saveas command?
Afficher commentaires plus anciens
There have been lots of questions on very similar issues already, but I can't quite get hold onto my specific problem. Say I have a cell vector with some names of chemical compounds and I want to produce plots of some properties of each one of those compounds, which I do using a simple loop. Now I would like to access the name of the compound when I am calling the saveas command, so the figure I am saving has the name of the compound and I therefore can quickly find it. I am getting the error message of using an invalid filename. My code looks something like this:
for I=1:10
x=propertyone(I,:);
y=propertytwo(I,:);
name=Names(I);
plot(x,y);
saveas(gcf,name,'jpeg')
end
I have no problem whatsoever naming the figures dynamically doing something like this:
for I=1:10
x=propertyone(I,:);
y=propertytwo(I,:);
name=Names(I);
plot(x,y);
saveas(gcf,['file',num2str(I)],'jpeg')
end
But I would very much like to have the proper names of the compounds instead of just a number. The problem seems to arise from defining the name variable within the loop, but I cannot figure out a solution.
I would appreciate any suggestions regarding this (rather specific) problem.
Best, Alex
Réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!