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?
0 件のコメント
採用された回答
Guillaume
2015 年 3 月 4 日
Convert your matrix into a row vector:
dlmwrite('myfile.txt', reshape(x', 1, []))
is one way to do it.
3 件のコメント
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 Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!