Question: Clean-up Write a function called CleanUp to tidy up a sentence and produce a string scalar. In the input sentence, some words are separated by


Clean-up Write a function called CleanUp to tidy up a sentence and produce a string scalar. In the input sentence, some words are separated by more than one space. The output should produce single spaces between words. Spaces should not appear at the beginning or end of the output sentence. While the input sentence could be either a string scalar or a character array, the output sentence must be a string scalar. Restriction: The function must use isstring, join, split and strtrim. Ex: >string-" ours is not to reason why "; stringout CleanUp(string) stringout - "ours is not to reason why" charArours is not to reason why stringout-CleanUp(charAr) stringout "ours is not to reason why" Your Function Save C Reset E MATLAB Documentation 1 function outputSentenceCleanUp (sentence) 2newText-strtrim(sentence); 3 newText-regexprep(newText, 'Is+'' 6 newText-split(newText) outputSentence join(newText): % Your code goes here % 5 newText-strip(newText); 7tf-isstring(newText) 8 10 12 end Code to call your function C Reset 1 stringot CleanUp(" ours is not to reason why ") Run Function Assessment: 2 of 3 Tests Passed Submit Check Cleanup(" ours is not to reason why ") returns stringout = "ours is not to reason why" Check CleanUp( ours is not to reason why returns stringOut"ours is not to reason why". Variable output must be of data type string. It is currently of type cell. Check where the variable is assigned a value. A string scalar is not returned. Check join, split, strtrim, and isstring are used
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
