I found a simple way to check whether a letter is a vowel in MATLAB (from here), simply like this :
is_vowel = numel(regexp(letter,'[aeiouAEIOU]'))>0
However, in my language (Turkish), the list of vowels is actually this:
is_vowel = numel(regexp(letter,'[aeiouöüıAEIOUÖÜİ]'))>0
this works correctly for ö
and ü
(Also for capitals) but it returns 0
for ı
and İ
. How can I solve this issue so it returns 1
for all the letters in the second list?
P.S. : I will use this code as a base for the latter part of my project which will involve things like getting the number of vowels in a word, so I'm open to alternative solutions too.
Also, if no other way is found, I'm ok with converting the letters to their English counterparts (like Ö
to O
etc.) but I prefer not changing them.
Thanks for any help!
Edit
I now see that the related part of my .m file is converted to this :
regexp(letter,'[aeiouöü?AEIOUÖÜ?]');
This is probably why regex is not working on those two characters. Any way to save these characters correctly in an *.m
file?
Solution
Thanks to @AndrasDeak :
function [b] = is_vowel(letter)
b = ismember(letter,['aeiouöüAEIOUÖÜ' 304 305]);
end