Solve Using Matlab: Function Name: camelCase Inputs: 1. (char) A string of some
ID: 668784 • Letter: S
Question
Solve Using Matlab:
Function Name: camelCase
Inputs:
1. (char) A string of some phrase to be converted to camel case
Outputs:
1. (char) The phrase converted to camel case
Function Description:
In this day and age of fancy technology and radical lingo, you decide that you’re going to text and email phrases in camel case to be as efficient as possible. Who needs spaces and vowels anyways?
Write a MATLAB function called camelCase that will take a phrase of characters and convert it to camel case. The algorithm to convert a string to camel case for this problem is as follows:
Capitalize the first letter of every individual word, except for the very first letter of the phrase. Lowercase every other letter.
Remove all spaces and extraneous special characters from the phrase.
Remove all vowels from the phrase, excluding those that are the first letter of a word.
For example, for the input: The output would appear as:
While the input
Would output the string:
Notes:
This problem must be completed using logical indexing.
The letter ‘y’ should not be considered a vowel for this function.
Hints:
The order in which you manipulate the input phrase will need to be taken into consideration.
Explanation / Answer
function str = camelCase(str) % convert underscore-based names to CamelCase % e.g. 'one_two_three' --> 'OneTwoThree' % 'oneTwoThree' --> 'OneTwoThree' % '#$one_two,three' --> 'OneTwoThree' str = regexprep(str, '(^|[_W]+)([a-zA-Z]?)', '${upper($2)}');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.