- 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?
3 次查看(过去 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.
0 个评论
采纳的回答
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:
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 Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!