Difference between using single quotes ('xyz') and double quotes ("xyz") in formatspec
61 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ranjan Sonalkar
il 1 Giu 2021
Commentato: Steven Lord
il 1 Giu 2021
What is the difference between using single quotes ('xyz') and double quotes ("xyz") in formatspec?
0 Commenti
Risposta accettata
James Tursa
il 1 Giu 2021
Modificato: James Tursa
il 1 Giu 2021
In MATLAB, single quotes ' ' are used to create char type variables, and double quotes " " are used to create string type variables.
Char type variables are simple rectangular arrays of characters:
String type variables are OOP objects that have many features that are not available with char type variables, such as creating arrays of varying length strings:
1 Commento
Steven Lord
il 1 Giu 2021
One difference that's specific to the circumstances of using them in a format specifier of a call to sprintf is that the result will be the same type as the format specifier as stated in the section of the documentation page that describes the str output.
c = sprintf('%d %d %d', 1:3)
s = sprintf("%d %d %d", 1:3)
whos c s
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Whos in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!