Capitalize only the first letter of a character

10 次查看(过去 30 天)
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

采纳的回答

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

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by