How to export a matrix in a text file?

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Più risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by