Export to .csv with specific notation

9 Ansichten (letzte 30 Tage)
Ioanna Stamataki
Ioanna Stamataki am 26 Jul. 2018
Kommentiert: Ioanna Stamataki am 26 Jul. 2018
Hello,
From matrix A (A = [0 1; 1 2; 2 3] I need to create a .csv file in the following format:
{0.000,1.000}, /new line
{1.000,2.000}, /new line
{2.000,3.000}, /new line
I am managing to import it into an array but I do not know how to specify the formatSpec of the output. Any help would be appreciated.
Many thanks, Ioanna

Akzeptierte Antwort

Stephen23
Stephen23 am 26 Jul. 2018
Bearbeitet: Stephen23 am 26 Jul. 2018
[fid,msg] = fopen('name.csv','wt');
assert(fid>=3,msg)
fprintf(fid,'{%.3f,%.3f},\n',A.');
fclose(fid);
The file it produces is attached, and looks like this:
{0.000,1.000},
{1.000,2.000},
{2.000,3.000},

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by