Some problems with “writematrix” function。

조회 수: 14 (최근 30일)
liang deng
liang deng 2020년 11월 24일
편집: Stephen23 2025년 4월 29일
I want to not write double quotes when using the “writematrix” function to write a character matrix to txt.
Can you help me?
  댓글 수: 1
Stephen23
Stephen23 2025년 4월 29일
편집: Stephen23 2025년 4월 29일
Lets try it now with a character matrix:
A = ['0110';'1010'];
writematrix(A,'test.txt')
type test.txt
0110 1010
No double quotes added.
Lets try a string array:
A = ["0110";"1010"];
writematrix(A,'test.txt')
type test.txt
0110 1010
No double quotes added.
What does reproduce your screenshot is when the data itself contains trailing commas (i.e. field delimiters):
A = ['0110,';'1010,'];
writematrix(A,'test.txt')
type test.txt
"0110," "1010,"
Solution: remove the trailing commas from the data OR specify the QuoteStrings option:
A = ['0110,';'1010,'];
writematrix(A,'test.txt', "QuoteStrings","none")
type test.txt
0110, 1010,

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by