Check if UTF-8 is a vowel in MATLAB

I found a simple way to check if a letter is a vowel in MATLAB (from here ), just like this:

is_vowel = numel(regexp(letter,'[aeiouAEIOU]'))>0

However, in my language (Turkish), the list of vowels is actually as follows:

is_vowel = numel(regexp(letter,'[aeiouöüıAEIOUÖÜİ]'))>0

this works correctly for öand ü(also for capitals), but returns 0for ıand İ. How can I solve this problem so that it returns 1for all letters in the second list?

PS: I will use this code as the basis for the last part of my project, which will include things like getting the number of vowels in one word, so I am also open to alternative solutions.

In addition, if no other method is found, I agree with the conversion of the letters to their English counterparts (for example, from Öto O, etc.), but I prefer not to change them.

Thanks for any help!

Edit

Now I see that the related part of my .m file is converted to this:

regexp(letter,'[aeiouöü?AEIOUÖÜ?]');

This is probably why regex does not work on these two characters. Any way to properly save these characters in a file *.m?

Decision

Thanks @AndrasDeak:

function [b] = is_vowel(letter)
b = ismember(letter,['aeiouöüAEIOUÖÜ' 304 305]);
end
+4
source share
1 answer

, , matlab, . , , .

ismember , :

b = ismember(letter,['aeiouöüAEIOUÖÜ' 304 305]);

, .

, :

is_vowel = @(letter) ismember(letter,['aeiouöüAEIOUÖÜ' 304 305]);
+4

Source: https://habr.com/ru/post/1608223/


All Articles