Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB trouble! Write a function called CleanUp to tidy up a sentence and produce a string scalar. In the input sentence, some words are separated
MATLAB trouble!
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...
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" >charAr' ours is not to reason whystringout CleanUp (charAr) stringout "ours is not to reason why" Your Function Save C Reset B MATLAB Documentation 1 function outputSentence- CleanUp (sentence) 2 3 sentence- strtrim(sentence) 7 outputsentence regexprep ( sentence, \s+' , '); 10 end Code to call your function C Reset 1stringout-CleanUp(" ours is not to reason why") Run Function Previous Assessment: Incorrect Submit Check CleanUp(" ours is not to reason why ") returns stringOut "ours is not to reason why" Check CleanUpf 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 char. Check where the variable is assigned a value. A string scalar is not returned Check join, split, strtrim, and isstring are used. The submission must contain the following functions or keywords: join, split, isstring The functions join, split, strtrim, and isstring should be used. Trouble with labStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started