How to save matrix to .dat file in standard notation
28 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi!
I would like to save a binary matrix 'A' to the file 'output.dat' without scientific notation formatting. For instance the matrix A has the (1,1) element, A(1,1) = 0. But it is saved as 0.0000000..e+00, when I'd simply like to to be saved as just 0.
I'm currently using the following basic save function,
A = [0 1 1 0; 0 0 0 1; 1 0 1 0; 0 0 0 0] % Example binary matrix A
save(['output=' num2str(i+1) '.dat'],'A','-ascii');
any help would be greatly appreciated.
Thank you!
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Avr 2019
You cannot do that using save -ascii: save -ascii uses a fixed format.
Probably the easest way is
filename = sprintf('output=%d.dat', i+1);
dlmwrite(filename, A, ' ' )
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur String Parsing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!