Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB: Capitalize first letter in string array

Tags:

string

matlab

How am I supposed to access, let's say, the first character of every member of a string array? For example, I would like to capitalize the first letter of each word.

str = ["house", "stone", "summer"]
like image 340
Andi Avatar asked Dec 06 '22 12:12

Andi


1 Answers

You can do it using conventional slicing. To get a capital of a letter I used upper function

for i=1:size(str,2)
    str{i}(1)=upper(str{i}(1))
end
like image 141
Mikhail Genkin Avatar answered Jan 12 '23 16:01

Mikhail Genkin