Capitalize only the first letter of a character

12 visualizaciones (últimos 30 días)
Ivan Mich
Ivan Mich el 25 de En. de 2021
Editada: Ive J el 25 de En. de 2021
How to Capitalize only the first letter of a character ? upper function capitalize all the letters. I want only to make this change ONLY for the first letter.
Thank you in advance

Respuesta aceptada

David Hill
David Hill el 25 de En. de 2021
Likely a better way.
a='my name';
a(1)=upper(a(1));

Más respuestas (1)

Ive J
Ive J el 25 de En. de 2021
Editada: Ive J el 25 de En. de 2021
str = "dogs are better than cats";
regexprep(str ,'(\<\w{1})', '${upper($1)}')
"Dogs Are Better Than Cats"

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by