Can anyone help me do this on MATLAB? Please do not change the variable names. T
ID: 3777068 • Letter: C
Question
Can anyone help me do this on MATLAB? Please do not change the variable names. Thank you very much.
2. (10 points Write a function called analyzeText that accepts a string as input and (1)counts the number of words; (2) identifies the length of the longest word; and (3) identifies the greatest number of vowels (a, e, i, o, u in a word. The function will be called as follows: InumWords, maxWordLength, maxNumVowelsl analyze Text (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 Following are examples of correct function behavior Inw, mwl, mnv] analyze Text The woods are lovely dark and deep') nW mwl minv Inw, mwl, mnv] analyze Text But I have promises to keep' nW mwl minv If you are using the strtok function to tokenize the string, read the release notes regarding its behavior: https ://www.mathworks.com/help/matlab/ref/strtok.htmlExplanation / Answer
Solution:
Function to display the string operations using MATLAB :
char AnalyzeTextChar(char* str)
{
// Create array to keep the count of individual
// characters and initialize the array as 0
int numWords={20}
int maxWordLength={10}
int count[ASCII_SIZE] = {0};
int maxNumVowels={10}
str1 = 'Computer Science'
// Construct character count array from the input
// string.
int len = strlen(str);
for (int i=0; i<len; i++)
count[str[i]]++;
int maxNumVowels = -1; // Initialize max count
char result; // Initialize result
// Traversing through the string and maintaining
// the count of each character
for (int i = 0; i < len; i++) {
if (maxNumVowels < count[str[i]]) {
maxNumVowels = count[str[i]];
result = str[i];
}
}
sprintf('%s ', str1)
return result;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.