How can I format columns when writing to a text file?

5 次查看(过去 30 天)
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.

采纳的回答

Kyle Pastor
Kyle Pastor 2018-2-2
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:
  1. Take your matrix of doubles (A) and convert it into a table
  2. use the writetable(A) command,
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by