Filter löschen
Filter löschen

How can I save matrix to .txt file?

231 Ansichten (letzte 30 Tage)
Teemu
Teemu am 13 Mär. 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?

Akzeptierte Antwort

Friedrich
Friedrich am 13 Mär. 2013
Bearbeitet: Friedrich am 13 Mär. 2013
Hi,
use dlmwrite
a = rand(64,60);
dlmwrite('filename.txt',a)
  5 Kommentare
Mohammad Homayounpour
Mohammad Homayounpour am 7 Apr. 2020
Yes
Aravind Rao Karanam
Aravind Rao Karanam am 8 Jan. 2022
dlmwrite is not recommended anymore. Use writematrix
a = rand(64,60);
writematrix(a, 'filename.txt')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

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

Almuthana Alharbi
Almuthana Alharbi am 11 Apr. 2018
Thanks

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by