Capitalize only the first letter of a character

10 vues (au cours des 30 derniers jours)
Ivan Mich
Ivan Mich le 25 Jan 2021
Modifié(e) : Ive J le 25 Jan 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

Réponse acceptée

David Hill
David Hill le 25 Jan 2021
Likely a better way.
a='my name';
a(1)=upper(a(1));

Plus de réponses (1)

Ive J
Ive J le 25 Jan 2021
Modifié(e) : Ive J le 25 Jan 2021
str = "dogs are better than cats";
regexprep(str ,'(\<\w{1})', '${upper($1)}')
"Dogs Are Better Than Cats"

Catégories

En savoir plus sur Characters and Strings 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