lundi 23 février 2015

How can I change only vowels from uppercase to lowercase and vice versa (MATLAB)

I have to change every vowel on a string to upper or lower case depending what it already is.. so "UPPERCASE lowercase" becomes "uPPeRCaSe lOwErcAsE"


So far I have had no success with this aproach



str= 'UPPERCASE lowercase';
vow = 'aeiou';
vowm = 'AEIOU';

for k = 1:5

if str(str == vow(k))
str(str == vow(k))= vowm(k);
else
if str(str == vowm(k))
str(str == vowm(k))= vow(k);


Expected output: "uPPeRCaSe lOwErcAsE"


Actual output: "uPPERCASE lOwErCAsE"


I am extremely new to matlab and im kinda lost. i aprecciate your help


Aucun commentaire:

Enregistrer un commentaire