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

The objective is use the function words() which chops a sentence into words and

ID: 3625634 • Letter: T

Question

The objective is use the function words() which chops a sentence
into words and stores them into a 2D char array.

I need to write a function that takes a
string as its input, chops the sentence into words, and for each
word, capitalizes the 1st letter and forces all other letters to be
lower case. Fox example, if the input parameter is `this is an
american TRADITION', the return value of your function should
be a valid 2D char array: (please help me write this phrase itself :)
This
Is
An
American
Tradition
Your function will call words(), and the words() function

--I have reached this much--
function all_words = words(input_string)
remainder = input_string;
all_words = '';
while (any (remainder))
   [chopped,remainder] = strtok(remainder);
   chopped = strcat(upper(chopped(1)),lower(chopped(2:length(chopped))));
   all_words = strvcat(all_words,chopped); % vert concat
end
end


The Format needs to be only 1 file -the function file.

Explanation / Answer

remainder =input_string;

for k = 1:5

    [token, remainder] = strtok(remainder);

    token=strcat(upper(token(1)),lower(token(2:length(token))));

    token

end

>> words('this is an American tradition')

token =

This

token =

Is

token =

An

token =

American

token =