Capitalize only the first letter of a character

13 Ansichten (letzte 30 Tage)
Ivan Mich
Ivan Mich am 25 Jan. 2021
Bearbeitet: Ive J am 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

Akzeptierte Antwort

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

Weitere Antworten (1)

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

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by