Writing a matrix to a text file with proper space

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

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?)
dlmwrite() with 'newline', 'pc' if you want to be extra sure that the data will be readable under that obsolete program Notepad
Hi. thanks for the reply. this is what i tried, all came out messed up.
dlmwrite('EvoUnsuc.txt',EvoUnsuc);
dlmwrite('EvoUnsuc.txt', EvoUnsuc, 'delimiter', '\t','newline', 'pc');
My code has numbers with high precioion. Ranging from E^-11 to 10^8.. I'm using a macbook pro if that matters
thank you!!
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
Ok. This is what I meant. (attached screen shot) Any idea? :(
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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by