Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write your own MATLAB function named count vowels that meets the following speci

ID: 3690726 • Letter: W

Question

Write your own MATLAB function named count vowels that meets the following specifications: The input argument is a string (i.e., a vector that contains character values). Use a for loop inside the function to access the vector elements (i.e., the characters): Count the number of lowercase vowel characters ('a', 'e', 'i', 'o', 'u') that are in the string. Return these two output arguments: Number of vowels in the string What percentage (in decimal) of the total characters were vowels If the input string is 'I live in Portland.', there are 5 lowercase vowels and a total of 19 characters (spaces and period are included). The function should return 5 and 0.2632 (i.e., 5/19).

Explanation / Answer

by using regular expression we could match the vowels and finally count the number of vowels. --> here x is a charcter array. length(regexpi(x, 'a|e|i|o|u'))