write matrices in notepad

7 ビュー (過去 30 日間)
tevzia
tevzia 2013 年 9 月 30 日
回答済み: Azzi Abdelmalek 2013 年 9 月 30 日
Hi I try to write result as a notepad or an excel file. I am using dlmwrite() however i didnt find out how to write each number in a new line.
I have a matrices with 100 values which are shown on the command window like this.
Columns 1 through 21
4 1 1 0 0 0 2 4 1 4 2 4 3 1 2 1 2 1 2 2 3
Columns 22 through 42
4 3 4 1 0 4 2 1 3 3 3 3 0 3 1 0 3 2 1 1 2
I used :
dlmwrite('myfile.txt', M, 'delimiter', ' ', 'newline', 'pc')
and the notepad file is :
4 1 1 0 0 0 2 4 1 4 2 4 3 1 2 1 2 1 2 2 3 4 3 4 1 0 4 2 1 3 3 3 3
but i want them like
4
1
1
0
0
0
2
4
1
How can i print my file like this.
Thank you

採用された回答

Wayne King
Wayne King 2013 年 9 月 30 日
I think you can do this:
Either create a column vector in MATLAB and then just use save -ascii
For example:
x = randn(1,500);
x = x';
save('test.txt','x','-ascii')
Use '\n' as the delimiter
x = randn(1,500);
dlmwrite('test.txt',x,'delimiter','\n','newline','pc');
  1 件のコメント
tevzia
tevzia 2013 年 9 月 30 日
\n didnt work somehow but coverting to column is a good idea.
Thank you

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 30 日
dlmwrite('myfile.txt', M', 'newline', 'pc')

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by