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')

 Respuesta aceptada

Paulo Silva
Paulo Silva el 12 de Jun. de 2011

2 votos

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 comentarios

Hassan
Hassan el 12 de Jun. de 2011
thanks Paula for the help.
David Ebert
David Ebert el 29 de Sept. de 2022
Helped me a lot, Paolo, thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Jun. de 2011

Comentada:

el 29 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by