Question: Function Name: foodPrep () Inputs: 1. ( char ) A 1 x N char vector containing a message Outputs: 1. (char) a 1X N char
Function Name: foodPrep()
Inputs:
1. ( char ) A 1 x N char vector containing a message
Outputs:
1. (char) a 1X N char vector of the decoded sentence
Topics: (char vectors),(LHS/ RHS indexing), (colon operator), (strfind/strrep), (casting)
Background:
You're a broke and hungry student, but your grandma called you and told you
about food prepping for the week to save both time and money! Your grandma
texted you her favorite cooking phrases and advice over her old cracked iPhone 12, but the
message came out jumbled, and you are unable to understand it.
Function Description:
Given a character vector containing a message, follow these steps in the correct order
to decipher it:
1. Starting with the first index of the char vector, shift every third index up 2 ASCII
values (for example, 'q' 's' )
2. Replace all underscores '_' with a single space
3. Capitalize the first letter of every word in the sentence
Example:
mixed = 'qalr_tfe_uatcr_`efmre]boglilg_gt'
fixed = foodPrep(mixed)
fixed 'Salt The Water Before Boiling It'
Notes:
Make sure to capitalize the first letter of every word, including the first word (step 3)
Words will be separated by a single underscore
The original statement may contain special characters, but shifting should remove all
special characters (except underscores), and the final output should not contain any
Hints:
You may need to cast the char vector to a different data type to perform a
mathematical "shift" for step 1
The letters at the beginning of a word are always one index after a space except for the
very first character of the string
The colon operator may be useful
Please solve without using Conditional statements and Iterations to receive an up vote.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
