Thread Subject: what's wrong in my dlmwrite?

Subject: what's wrong in my dlmwrite?

From: Kuo-Hsien

Date: 19 Feb, 2009 17:02:02

Message: 1 of 3

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');
dlmwrite('Elora_met04_08_class.dat',Elora_met05_class,'-append','precision','%0.7g','delimiter','\t');
dlmwrite('Elora_met04_08_class.dat',Elora_met06_class,'-append','precision','%0.7g','delimiter','\t');
dlmwrite('Elora_met04_08_class.dat',Elora_met07_class,'-append','precision','%0.7g','delimiter','\t');
dlmwrite('Elora_met04_08_class.dat',Elora_met08_class,'-append','precision','%0.7g','delimiter','\t');

Subject: what's wrong in my dlmwrite?

From: Kuo-Hsien

Date: 21 Feb, 2009 17:01:01

Message: 2 of 3

"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');
> dlmwrite('Elora_met04_08_class.dat',Elora_met05_class,'-append','precision','%0.7g','delimiter','\t');
> dlmwrite('Elora_met04_08_class.dat',Elora_met06_class,'-append','precision','%0.7g','delimiter','\t');
> dlmwrite('Elora_met04_08_class.dat',Elora_met07_class,'-append','precision','%0.7g','delimiter','\t');
> dlmwrite('Elora_met04_08_class.dat',Elora_met08_class,'-append','precision','%0.7g','delimiter','\t');

Subject: what's wrong in my dlmwrite?

From: Steven Lord

Date: 23 Feb, 2009 15:55:32

Message: 3 of 3


"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

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