필터 지우기
필터 지우기

write matrices in notepad

조회 수: 5 (최근 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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by