How to export a matrix in a text file?

4 ビュー (過去 30 日間)
afrya
afrya 2014 年 1 月 10 日
コメント済み: Raghav Rathi 2020 年 7 月 27 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 10 日
A=[1 2
3 4
5 6]
dlmwrite('dataexport.txt',A,'delimiter','\t','newline','pc')
  1 件のコメント
afrya
afrya 2014 年 1 月 10 日
Thanks for your answer akhi

サインインしてコメントする。

その他の回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 1 月 10 日
Try dlmwrite('dataexport.txt',A,'newline','pc').
  3 件のコメント
afrya
afrya 2014 年 1 月 10 日
Thanks for your answer
Raghav Rathi
Raghav Rathi 2020 年 7 月 27 日
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by