Re: Export data to CSV and Format of numbers



Learner <cnfengshuang@xxxxxxxxx> wrote in message <4374cd39-
d419-481d-a3b9-b770c620f6c9@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:487929

Hi ,

I want to export a matrix to csv, but found the format of
the numbers
are all "short" in the CSV file. I used "format long" in
my codes, and
the number format of data is correct when I open it in
Matlab.

How can I get the exported data in the right format?

Thank you!

Learner

The "format long" command only affects how numbers are
displayed on the screen. It doesn't affect how numbers are
written into files.

If you want to write data into a CSV file with a specified
precision, use the DLMWRITE function. Specify the
delimiter to be ',' and specify the precision to what you
want. For example:

A = rand(3,3);
dlmwrite('test.csv',A,...
'delimiter',',','precision','%0.16f')

For more info type

doc dlmwrite
.



Relevant Pages

  • Re: Code looping through files new line
    ... That was the alert I was getting about the SYLK. ... was in csv format and questioned if I wanted to save it in that format. ... I click OK and the file opens up, with the ***.csv in the header bar. ...
    (microsoft.public.excel.programming)
  • Re: Code looping through files new line
    ... was in csv format and questioned if I wanted to save it in that format. ... I click OK and the file opens up, with the ***.csv in the header bar. ... Otto and I have talking this morning and here are some ...
    (microsoft.public.excel.programming)
  • Re: starting with OpenOffice base
    ... How am I to import a .csv ";" separated text file into base? ... 1.Export the desired data from the source database in a text format. ... 3.This opens the Export of text files dialogue box, ...
    (comp.os.linux.misc)
  • Re: starting with OpenOffice base
    ... How am I to import a .csv ";" separated text file into base? ... To exchange data in a text format use the OpenOffice.org Calc import/export filter. ... 1.Export the desired data from the source database in a text format. ... Once the data is in a OpenOffice.org Calc spreadsheet, you can edit it as needed. ...
    (comp.os.linux.misc)
  • Re: Code looping through files new line
    ... Tom, here is the answer to your question. ... was in csv format and questioned if I wanted to save it in that format. ... I click OK and the file opens up, with the ***.csv in the header bar. ...
    (microsoft.public.excel.programming)