btbam91
- 91
- 0
Hey guys.
So this problem asks me write a function that accepts a string, and outputs an array of class logical where the true values are the vowels and everything is false.
As of now, I have:
And when I run this function for say the string 'AAA' I get 111(The problem with this is that it's a 1x1 array of 111, I need a 1x3 array) as an output, when I'm trying to get a logical array of 1 1 1.Thanks for the guidance.
So this problem asks me write a function that accepts a string, and outputs an array of class logical where the true values are the vowels and everything is false.
As of now, I have:
function array = arraylogical(c)
%Purpose: This function accepts a string, c, and returns a logical array in
%which vowels are true and consonants are false.
%Find length of c
n = length(c);
%Initiate for loop
for ii = 1:n
if c(ii) == 'A'
c(ii) = '1';
elseif c(ii) == 'E'
c(ii) = '1';
elseif c(ii) == 'I'
c(ii) = '1';
elseif c(ii) == 'O'
c(ii) = '1';
elseif c(ii) == 'U'
c(ii) = '1';
elseif c(ii) == 'a'
c(ii) = '1';
elseif c(ii) == 'e'
c(ii) = '1';
elseif c(ii) == 'i'
c(ii) = '1';
elseif c(ii) == 'o'
c(ii) = '1';
elseif c(ii) == 'u'
c(ii) = '1';
else
c(ii) = '0';
end%if
end%for
end%function
And when I run this function for say the string 'AAA' I get 111(The problem with this is that it's a 1x1 array of 111, I need a 1x3 array) as an output, when I'm trying to get a logical array of 1 1 1.Thanks for the guidance.