Question: Inputs: (char) A sentence to be modified (char) The word to be replaced in the sentence (char) The word to replace with Outputs: 1. (char)

Inputs:

  1. (char) A sentence to be modified

  2. (char) The word to be replaced in the sentence

  3. (char) The word to replace with

Outputs:

1. (char) Modified sentence Banned Functions:

strrep()

Background:

The ctrlF and replace feature on your laptop is broken and you need to use MATLAB to do the job!

Function Description:

Your function will replace one word within your sentence with another, indicated by your input variables. Your output will be the entire modified sentence with the replaced word.

Example:

original = 'My favorite class is physics!'; wordFind = 'physics'; wordReplace = 'CS1371'; out = repWord(original, wordFind, wordReplace); out 'My favorite class is CS1371!'

Notes:

  • There will be exactly one instance of the word you will replace (it will not appear twice in a sentence)

  • Your function should be case sensitive (i.e. 'MATLAB' and 'matlab' are not the same)

    Hints:

  • The strfind() function will be useful!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!