How to export a matrix in a text file?
Show older comments
Hello,
I want to save a matrix in a text file with the data organised in columns. Exemple:
A=
1 2
3 4
5 6
I want to get a text file in which A looks like :
A=
1 2
3 4
5 6
When I used the following function dlmwrite('dataexport.txt',a,'delimiter','\t'), I get
a text file with A=1 2 3 4 5 6
Thanks in advance
Accepted Answer
More Answers (1)
Mischa Kim
on 10 Jan 2014
1 vote
Try dlmwrite('dataexport.txt',A,'newline','pc').
3 Comments
Mischa Kim
on 10 Jan 2014
...or dlmwrite('dataexport.txt',A,'newline','pc','delimiter',' ').
afrya
on 10 Jan 2014
Raghav Rathi
on 27 Jul 2020
I am getting the following error while using dlmwrite('dataexport.txt',A,'newline','pc','delimiter',' ').
" Error using writematrix (line 156)
Invalid parameter name: newline. "
Is there any change in writemartix now?
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!