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