How can I save matrix to .txt file?

382 vues (au cours des 30 derniers jours)
Teemu
Teemu le 13 Mar 2013
I have numerical matrix size of 64*60 and I like to save it to .txt file. How can I do it as easy as possible? without repeating %d with fprintf?

Réponse acceptée

Friedrich
Friedrich le 13 Mar 2013
Modifié(e) : Friedrich le 13 Mar 2013
Hi,
use dlmwrite
a = rand(64,60);
dlmwrite('filename.txt',a)
  5 commentaires
Mohammad Homayounpour
Mohammad Homayounpour le 7 Avr 2020
Yes
Aravind Rao Karanam
Aravind Rao Karanam le 8 Jan 2022
dlmwrite is not recommended anymore. Use writematrix
a = rand(64,60);
writematrix(a, 'filename.txt')

Connectez-vous pour commenter.

Plus de réponses (2)

Sudhir Rai
Sudhir Rai le 17 Nov 2020
Use this to get perfect matrix in .txt
X = rand(64,60)
save ('filename.txt', 'X', '-ascii')

Almuthana Alharbi
Almuthana Alharbi le 11 Avr 2018
Thanks

Catégories

En savoir plus sur Characters and Strings 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!

Translated by