Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top