Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: help to save file from histogram
Date: Wed, 4 Nov 2009 04:46:00 +0000 (UTC)
Organization: PatientsLikeMe
Lines: 34
Message-ID: <hcr0u8$bb1$1@fred.mathworks.com>
References: <hcquja$ht8$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257309960 11617 172.30.248.37 (4 Nov 2009 04:46:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 04:46:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1841757
Xref: news.mathworks.com comp.soft-sys.matlab:582238


"uny gg" <illinois.ks@gmail.com> wrote in message <hcquja$ht8$1@fred.mathworks.com>...
> Hello all
> 
> I am trying to save the histogram image as a file.. (any format e.g. png, jpeg. etc)
> The problem is that I have to do this continuous many times.. 
> 
> Here is may code.
> 
> function dim = PatchDistHistogram(data)
>     dim = size(data);
>     nFeature = dim(2);
>    
>     for i=1:nFeature
>       hist(data(:,i));
>       fname = ['astro' int2str(i) '.png'];
>       fname
>       print fname -dpng 
>     end
>     
> end
> 
> 
> When I run this code, it shows that each histogram in screen, however,
> There is no file which is created from this.
> 
> I am not sure.. what is problem.
> 
> Could you please somebody help me with this? 

Use the functional form of print when you have a string with the filename.  I think the syntax, the way you have created "fname", should be

>> print('-dpng',fname)

If that does not work, look at "help print" for the functional method syntax.