put a space in a text

85 visualizzazioni (ultimi 30 giorni)
Hassan
Hassan il 12 Giu 2011
Commentato: David Ebert il 29 Set 2022
If we run the following code we will see that there is no space between 'is' and number '1'. I wonder how I can put a space in a text.
s=strcat('this is ',num2str(1),' my cat')

Risposta accettata

Paulo Silva
Paulo Silva il 12 Giu 2011
s=['this is ' num2str(1) ' my cat']
strcat ignores trailing ASCII white space characters and omits all such characters from the output. White space characters in ASCII are space, newline, carriage return, tab, vertical tab, or form-feed characters, all of which return a true response from the MATLAB isspace function. Use the concatenation syntax [s1 s2 s3 ...] to preserve trailing spaces. strcat does not ignore inputs that are cell arrays of strings.
  2 Commenti
Hassan
Hassan il 12 Giu 2011
thanks Paula for the help.
David Ebert
David Ebert il 29 Set 2022
Helped me a lot, Paolo, thanks!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by