Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions

Question

Connect with your audience

Answered: 1 week ago