- 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?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Conor Dixon
el 2 de Feb. de 2018
Comentada: Conor Dixon
el 2 de Feb. de 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 comentarios
Respuesta aceptada
Kyle Pastor
el 2 de Feb. de 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!
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!