You can use the function isstrprop with the category 'lower' and 'upper' to identify the specific characters. Then use the commands upper and lower to change the case.
An alternative is to use a comparison:
str = 'aSd12Bqm'
low = (str >= 'a' & str <= 'z')
high = (str >= 'A' & str <= 'Z')
Now upper and lower can be useful again. But you can try it with calculations of the ASCII code also:
str = 'a'
str2 = str + ('A' - 'a')
A smart trick is to flip the 5th bit of the ASCII representation, if the character is a letter:
str = 'Aa'
You have to use a mask to affect the letters only. See the creation of low and high above, which can be combined.