- 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 (최근 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!