MATLAB PROBLEM Please write a MATLAB function to find the FI

MATLAB PROBLEM

Please write a MATLAB function to find the FIRST vowel in a word, the function header is

function v=findfirstvowel(word)

For example, if test by typing in the name \"mike\" (as input \"word\"), the first vowel (as output v) should be letter \"i\".

Hint: the input/output variables` type should a string data type (char).

Solution

Modified Program:

clc
close all;
str = input(\'Please Enter the Word:\',\'s\');% Reading the input from command window
%v = findfirstvowel(str); % Calling function program
l = length(str); % measuring length of input word
vwl = \'aeiou\'; % defining vowels
for i=1:l
k = str(i);
for j=1:5
if (k == vwl(j)) % Checking each letter in input word with vowels
%v = vwl(j); % Returning found vowel to main program
disp(\'The first vowel detected is:\');
disp(vwl(j)); % Display the result in command window
return
end
end
end
%v=\'\';

%if isempty(v)
disp(\'No Vowels are Detected\'); % Result if no vowels are detected
%end

MATLAB PROBLEM Please write a MATLAB function to find the FIRST vowel in a word, the function header is function v=findfirstvowel(word) For example, if test by

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site