Borrar filtros
Borrar filtros

How can I save matrix to .txt file?

235 visualizaciones (últimos 30 días)
Teemu
Teemu el 13 de Mzo. de 2013
Comentada: Aravind Rao Karanam el 8 de En. de 2022
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?

Respuesta aceptada

Friedrich
Friedrich el 13 de Mzo. de 2013
Editada: Friedrich el 13 de Mzo. de 2013
Hi,
use dlmwrite
a = rand(64,60);
dlmwrite('filename.txt',a)
  5 comentarios
Mohammad Homayounpour
Mohammad Homayounpour el 7 de Abr. de 2020
Yes
Aravind Rao Karanam
Aravind Rao Karanam el 8 de En. de 2022
dlmwrite is not recommended anymore. Use writematrix
a = rand(64,60);
writematrix(a, 'filename.txt')

Iniciar sesión para comentar.

Más respuestas (2)

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

Almuthana Alharbi
Almuthana Alharbi el 11 de Abr. de 2018
Thanks

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by