Writing a matrix to a text file with proper space
Afficher commentaires plus anciens
Hi,
I tried writing a matrix to a text file using dlmwrite function, but it came out messed up.. no spaces and it looked terrible. How do I make it look spaced out properly between two columns and nicely aligned? I can't use xlswrite as the matrix has 2 million rows
Thanks!
6 commentaires
Star Strider
le 30 Jan 2019
Please post the relevant sections of the code you used, and specifically the dlmwrite call. (A description of your data would also be appropriate. Is it all double, or different data types?)
Walter Roberson
le 30 Jan 2019
dlmwrite() with 'newline', 'pc' if you want to be extra sure that the data will be readable under that obsolete program Notepad
itzhak mal
le 30 Jan 2019
Walter Roberson
le 30 Jan 2019
It is difficult to guess what you mean by "messed up". Perhaps you might like something like
dlmwrite('EvoUnsuc.txt', EvoUnsuc, 'delimiter', ' ', 'precision', '%20.16e')
or
save EvoUnsuc.txt EvoUnsuc -double -ascii
itzhak mal
le 30 Jan 2019
Walter Roberson
le 30 Jan 2019
Either dlmwrite with a 'precision' that has a leading count like the %20 that I showed (in which case each column will be the same size), or else fopen/fprintf/fclose using a format specifier that is appropriate for each column.
Réponses (0)
Catégories
En savoir plus sur Geometry and Mesh dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!