Question about delimiter for dlmwrite
조회 수: 11 (최근 30일)
이전 댓글 표시
Hello,
I want to seprate matrix elements in 8 spaces. However, when I wrote
dlmwrite( 'A.txt', Matrix, 'delimiter',' ')
error was occurred because delimiter requires a single character. How can I apply 8 spacesto separate matrix elements?
댓글 수: 0
채택된 답변
Walter Roberson
2011년 11월 16일
The documentation does imply that multiple characters should be acceptable.
Anyhow, you can use the Precision property to specify a format such as '%20.3f' . This is not exactly the same as leaving 8 characters between columns: it would be for using exactly 20 characters per column (in this example), which is a more typical requirement than 8 spaces between columns (which is difficult to keep consistent because different numbers print out with different widths.)
댓글 수: 4
Walter Roberson
2011년 11월 16일
If you need a fixed number of spaces between entries, then you are better off constructing the file yourself using fopen(), fprintf(), fclose()
But do you really need exactly 8 spaces between the entries, even if the entries are not the same length? For example, using _ to represent space:
7.2________0________1.1
3________-5.89________123.456
Or do you instead want each column to occupy a total of 8 spaces, as in
_____7.2_______0_____1.1
_______3___-5.89_123.456
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!