Write a matlab function called analyzeText that accepts a st

Write a matlab function called analyzeText that accepts a string as input and counts the number of words; identifies the length of the longest word; and identifies the greatest number of vowels (a, e, i, o, u) in a word. The function will be called as follows: [numWords, maxWordLength, maxNumVowels] = analyzeText(text) where the variable text contains the string supplied to the function, numWords returns the number of words, maxWordLength returns the length of the longest word in the string, and maxNumVowels returns the greatest number of vowels present in any word.

Solution

%m file

function [numWords,maxWordLength] = analyzeText(text)
space= strfind(text, \' \');

numWords=length(space)+1
max=0;
p=length(space);
for c= 1:p-1
if space(c+1)-space(c)>max
max=space(c+1)-space(c);
end
end
maxWordLength=max-1

end

%from console, text contains the string

>>analyzeText(text);

Write a matlab function called analyzeText that accepts a string as input and counts the number of words; identifies the length of the longest word; and identif

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site