Write matrix to text file
Mostrar comentarios más antiguos
Hello,
I am trying to write a matrix 'A' to a text file. I would like the data written to file like this:
A =
2 0 2 1 2 0
2 2 2 1 0 0
1 2 2 0 0 2
The code given below does not contain the 'A = '. How can I also include the 'A = ' to be written to the file also? Thanks for your help and time.
Here is the code that I have so far:
%%Generation of Random 3 x 6 Matrix
A = randi([0,2],3,6);
dlmwrite('myFile.txt',A,'delimiter','\t')
4 comentarios
Walter Roberson
el 7 de Mzo. de 2016
Editada: Walter Roberson
el 7 de Mzo. de 2016
Where are the tabs to appear on the "A =" line and on the empty line after that? Is there to be a tab before the first number on each line?
monkey_matlab
el 7 de Mzo. de 2016
Walter Roberson
el 7 de Mzo. de 2016
What should be the tabs on the 'A =' line and the visually empty line after that?
monkey_matlab
el 7 de Mzo. de 2016
Editada: monkey_matlab
el 7 de Mzo. de 2016
Respuestas (1)
Walter Roberson
el 7 de Mzo. de 2016
output = evalc(A);
fid = fopen('myFile.txt', 'wt');
fwrite(fid, output);
fclose(fid);
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
