Write a MATLAB function to find the first vowel in a word mi

Write a MATLAB function to find the first vowel in a word, mid test the program using your name as the input. The function header is function v=findfirstvowel (word)Please test your function for your first name. For example, if your first name is \"mike\" (as input word), the first vowel (as output t;) should be letter V. I suggest that you use lowercase letters for the input word, to make the problem easier.

Solution

MATLAB code:

function v = findfirstvowel(x)
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
for index = 1: length(x)
if x(index)==\'a\' || x(index)==\'e\' || x(index)==\'i\' || x(index)==\'o\' || x(index)==\'u\'
    v=x(index);
    break;
end
end

sample output

>> findfirstvowel(\'txsting\')

ans =

i

 Write a MATLAB function to find the first vowel in a word, mid test the program using your name as the input. The function header is function v=findfirstvowel

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site