Question: Matlab question: FunctionName: leafPile Inputs 1. ( char) A string representing all of the leaves 2(char) A color of leaf to search for Outputs: 1.

Matlab question:

FunctionName: leafPile

Inputs

1. ( char) A string representing all of the leaves

2(char) A color of leaf to search for

Outputs:

1. (double) The number of leaves of that specific color

Background

Fall is in the air. This means that means leaves are on the ground! You walk outside and

see thousands of leaves blanketing campus and immediately want to count the number of

leaves of a specific color there are. Assuming one of your 1371 TAs has meticulously

documented the color of every leaf on campus, use your new MATLAB skills to find the number

of leaves of that specific color in the pile.

Function Description:

Write a function that takes in a character vector containing the colors of all the leaves in

a pile as the first input, and a single color as the second input. Find the number of times that the

specified color occurs in the first input. The search should be caseinsensitive, meaning that

you should ignore whether letters or words are uppercase or lowercase when searching through

the string.

Example

>>pile = 'red brOwn green yellow BrOwN MATLAB GrEEn rEd purple Blue brown '

>>color = 'brown';

>>num = leafPile(pile, color)

==> num = 3

Notes

The function should notbe case sensitive. So RED and red should both count if the

second input is Red

Hints

The function strfind() will be very 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!