- Take your matrix of doubles (A) and convert it into a table
- use the writetable(A) command,
How can I format columns when writing to a text file?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Conor Dixon
am 2 Feb. 2018
Kommentiert: Conor Dixon
am 2 Feb. 2018
I have a 128x19461 double that I want to save as a text file.
I am using:
output = evalc('A'); % A is the matrix
fid = fopen('SamplesTimestampsnew.txt', 'wt');
fwrite(fid, output);
fclose(fid);
This saves it to the text document, but it formats it as "columns 1 through 6, columns 7 through 13" etc.
What am I missing here? Surely it must be simple! Thank you.
0 Kommentare
Akzeptierte Antwort
Kyle Pastor
am 2 Feb. 2018
Hey Conor,
I think what is happening is that it is converting the output of printing A into the console as a block of text. So basically it is just showing you what Matlab would print on the console.
May I suggest the following:
Notes on table:
See code below:
A=rand(10,10); % Random 10x10 array of doubles
A = table(A); % converts it into a table (now you can even rename columns)
writetable(A,'./SamplesTimestampsnew.csv');
And there you should have a nice .csv formatted table!
Hope this helps!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Export 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!