How can I write matrix elements to file Are contiguous , including a comma?

조회 수: 1 (최근 30일)
I use this function Are contiguous , x=[1 2;3 4;5 6]
x =
1 2
3 4
5 6
>> dlmwrite('myFile.txt', x)
and this what is written in myFile.txt
1,2
3,4
5,6
I want the result to be
1,2,3,4,5,6
Can I do this and how?

채택된 답변

Guillaume
Guillaume 2015년 3월 4일
Convert your matrix into a row vector:
dlmwrite('myfile.txt', reshape(x', 1, []))
is one way to do it.
  댓글 수: 3
Ameligege
Ameligege 2015년 3월 4일
If any one have another way by using dlmwrite ,I want to try it??
Guillaume
Guillaume 2015년 3월 4일
the ' is the transpose operator. I actually should have used the .', ctranspose in case you have complex numbers.
Because matlab is column major, you need to transpose the matrix before reshaping if you want to arrange by row.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by