Thread Subject: help to save file from histogram

Subject: help to save file from histogram

From: uny gg

Date: 4 Nov, 2009 04:06:02

Message: 1 of 4

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?

Subject: help to save file from histogram

From: the cyclist

Date: 4 Nov, 2009 04:46:00

Message: 2 of 4

"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.

Subject: help to save file from histogram

From: uny gg

Date: 4 Nov, 2009 05:01:35

Message: 3 of 4

Hello cyclist

Thank you for your response.
I also tried with that.. It doesn't work for me.
I looked at the "print" help manual. However, I could not figure out the way .. T.T


Any ideas?

Subject: help to save file from histogram

From: ImageAnalyst

Date: 4 Nov, 2009 11:41:32

Message: 4 of 4

I use Oliver Woodford's "export_fig" -- it's in the FileExchange.
People always have trouble trying to figure out saving figures
properly using the built in MATLAB routines. export_fig() does what
you want and expect and it's easy to use. It uses the built in
routines too but it knows how to set and use them properly, relieving
you of that pain.

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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com