Thread Subject: save figs in a loop

Subject: save figs in a loop

From: dome m

Date: 5 Nov, 2009 13:27:02

Message: 1 of 3

Hi,
I have a question about how to save matlab graphs (in .fig format) produced in a loop.
I have to plot the content of 100 columns from a data matrix, and I want to save them with the names graph1 graph2 and so on.
How can I do that?
I tried the following code that uses the 'saveas' command

for i=1:100
plot(data(:,i))
saveas(gcf,'graph' int2str(i),'fig')
end

but it doesn't work (it seems that matlab doesn't like int2str in the saveas command).
Any suggestion or idea?
Thanks in advance.

dome

Subject: save figs in a loop

From: dpb

Date: 5 Nov, 2009 14:09:14

Message: 2 of 3

dome m wrote:
...
> ... (it seems that matlab doesn't like int2str in the
> saveas command).
> Any suggestion or idea?

FAQ 4.9 at ML wiki

<http://matlabwiki.mathworks.com/MATLAB_FAQ>

--

Subject: save figs in a loop

From: Jane

Date: 6 Nov, 2009 00:27:06

Message: 3 of 3

for i=1:100
plot(data(:,i))
saveas(gcf,['graph', int2str(i)],'fig')
end

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com