Some problems with “writematrix” function。

1 vue (au cours des 30 derniers jours)
liang deng
liang deng le 24 Nov 2020
Modifié(e) : Stephen23 le 29 Avr 2025
I want to not write double quotes when using the “writematrix” function to write a character matrix to txt.
Can you help me?
  1 commentaire
Stephen23
Stephen23 le 29 Avr 2025
Modifié(e) : Stephen23 le 29 Avr 2025
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,

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Standard File Formats dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by