Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function (reverse sentence.m) that takes a single input argument which is a string containing a sentence (a sequence of words) and returns
Write a function (reverse sentence.m) that takes a single input argument which is a string containing a sentence (a sequence of words) and returns a single output argument which is a string containing the words in the input string in reverse order. For example, on input 'the quick brown fox jumps over the lazy dog', the function should return 'dog lazy the over jumps fox brown quick the'. Remember to think before you code. Have pencil and paper next to you and sketch your algorithm as pseudocode or flow diagram. I will get you started on this one: 1. Split the sentence at whitespace to form an array of words. 2. Reverse the array of words. 3. Construct the reversed sentence by joining the words in the array with spaces. Hint: MATLAB has built-in functions that perform each of those steps.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the MATLAB function reversesentencem that implements the steps you mentioned ...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