MATLAB: For loop that changes specific letters to numbers

for loophomework

I want to replace the vowels AEIOU with the number 0 and all other letters with the number 1. For example the output should be ans = [0 1 1 1 0] if the user inputs apple. I know I must be misunderstanding how to get the loop to go through my whole string. This is what I have managed so far.
party = input('What is your answer? ', 's');
n = length(party)
for i = 1:n
if i == 'A'
disp(0)
elseif i == 'B'
disp(1)
elseif i == 'C'
disp(1)
end
end

Best Answer

party = input('What is your answer? ', 's');
n = length(party)
for i = 1:n
if party(i) == 'A'
party(i) = 0;
elseif i == 'B'
party(i) = 1;
elseif i == 'C'
party(i) = 1;
end
end
disp( double(party) )
Related Question