How to export a matrix in a text file?

4 Ansichten (letzte 30 Tage)
afrya
afrya am 10 Jan. 2014
Kommentiert: Raghav Rathi am 27 Jul. 2020
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 10 Jan. 2014
A=[1 2
3 4
5 6]
dlmwrite('dataexport.txt',A,'delimiter','\t','newline','pc')

Weitere Antworten (1)

Mischa Kim
Mischa Kim am 10 Jan. 2014
Try dlmwrite('dataexport.txt',A,'newline','pc').
  3 Kommentare
afrya
afrya am 10 Jan. 2014
Thanks for your answer
Raghav Rathi
Raghav Rathi am 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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Export 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