質問

I would like to take a string and change the first letter of that string from upper to lower case in MATLAB. Any suggestions.

Example:

a = 'Upper';

% Do something to a

a = 'upper'

thank you in advance

役に立ちましたか?

解決

Use lower():

a = lower(a);

If you only need to change the first letter to upper case, try the following:

a = [lower(a(1)) a(2:end)];

Check out here for more info.

他のヒント

If you want all the letters to be lower case, then

s = 'String'
lowercase(s)

gives

string

If you want only the first letter, then

s = 'STring'
[lower(s(1)) s(2:end)]

gives

sTring
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top