Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: what's wrong in my dlmwrite?
Date: Mon, 23 Feb 2009 10:55:32 -0500
Organization: The MathWorks, Inc.
Lines: 46
Message-ID: <gnugtk$8ig$1@fred.mathworks.com>
References: <gnk3aa$6cd$1@fred.mathworks.com> <gnpc0d$3or$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1235404532 8784 144.212.105.187 (23 Feb 2009 15:55:32 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 23 Feb 2009 15:55:32 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:520215



"Kuo-Hsien" <mchangks@hotmail.com> wrote in message 
news:gnpc0d$3or$1@fred.mathworks.com...
> "Kuo-Hsien" <mchangks@hotmail.com> wrote in message 
> <gnk3aa$6cd$1@fred.mathworks.com>...
>> Dear all,
>>
>> I like to append all weather files in a single file, so I use dlmwrite 
>> function here. However, the format in the single file did not match up 
>> with the original files, even I address the 'precision.' Please advice 
>> me.
>>
>> Thanks,
>> Michael
>>
>> The original file format:
>>   2.0040000e+03   1.0000000e+00   0.0000000e+00   0.0000000e+00 
>> 0.0000000e+00   2.1210000e+02   0.0000000e+00   2.7155000e+02 
>> 2.4000000e+01   9.7640000e+04   3.4985847e-06
>>    2.0040000e+03   1.0000000e+00   0.0000000e+00   3.0000000e+01 
>> 0.0000000e+00   2.1140000e+02   0.0000000e+00   2.7155000e+02 
>> 2.4000000e+01   9.7640000e+04   3.4985847e-06
>>
>>
>> The single file format after the process of "dlmwrite"
>> 2004 1 0 0 0 212.1 0 271.55 24 97640 3.498585e-06
>> 2004 1 0 30 0 211.4 0 271.55 24 97640 3.498585e-06
>>
>>
>> Here is my code to take care of my purposes:
>>
>> delete('/Users/cks/Documents/Elora/weather/functions/Elora_met04_08_class.dat')
>> dlmwrite('Elora_met04_08_class.dat',Elora_met04_class,'-append','precision','%0.7g','delimiter','\t');

Look at "doc fprintf" for what the precision specifier '%g' does.  You don't 
want it to use the most compact of %e and %f, you want to use either %e or 
%f.  I'll let you figure out which one you want to make the output of 
DLMWRITE agree with your original file format.

*snip*

-- 
Steve Lord
slord@mathworks.com