Question: Main topics: If Statement, User functions, while loop. Find function 1 Fruit Classification Suppose you work for a company that processes fruits. To improve the

 Main topics: If Statement, User functions, while loop. Find function 1

Fruit Classification Suppose you work for a company that processes fruits. To

improve the efficiency in the shipping process, this company has acquired a

new sensor that reads the sourness of four different types of fruits:

oranges, pears, grapes, and apples. The sensor then classifies the fruits according

Main topics: If Statement, User functions, while loop. Find function 1 Fruit Classification Suppose you work for a company that processes fruits. To improve the efficiency in the shipping process, this company has acquired a new sensor that reads the sourness of four different types of fruits: oranges, pears, grapes, and apples. The sensor then classifies the fruits according to its voltage level as follows: Voltage Level Fruit Name in the Program 5 and 12 13 and 21 22 and 33 34 and 42 42 Mango Banana Strawberry Cherry Unknown (M) (B) (S) (C) Our goal will be design two functions. The first function will use a while loop to classify the fruit type, while the second function is going to do the same classification, but this time using the find function. 1. In order to test your functions you will have to use the following voltage values for the sourness sensor: volt = [18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; Note(s): Your program should produce output identical (when given the same input(s)) to the sample run(s) below, values and format. Outline: 2/6 1. Prog6_Drive.m Create a MATLAB Program titled Prog6_Drive.m and open the file. Clear command window and workspace window. Define the voltage matrix as shown in the Sample Run. Call fruitFind function and store the returned array in fruitList. Use while loop and fprintf to display the fruits details as shown in the first tabular table. Call fruit While function and store the returned array in fruitList. Use while loop and fprintf to display the fruits details as shown in the second tabular table. . 2. fruitFind.m Create a MATLAB Program called fruitFind.m and open the file. Setup an output argument called fruitList, and Volts input argument. Find all the voltage readings between 5 and 12 (inclusive), save it in a variable called V. Save 'M' in fruitList output argument on the same locations found in variable V. Find all the voltage readings between 13 and 21 (inclusive), save it in a variable called V. Save 'B' in fruitList output argument on the same locations found in variable V. Find all the voltage readings between 22 and 33 (inclusive), save it in a variable called V. Save 'S' in fruitList output argument on the same locations found in variable V. Find all the voltage readings between 34 and 42 (inclusive), save it in a variable called V. Save 'C' in fruitList output argument on the same locations found in variable V. Find all the voltage readings 42, save it in a variable called V. Save 'U' on fruitList output argument on the same locations found in variable V. 3. fruit While.m Create a MATLAB Program called fruit While.m and open the file. Setup an output argument called fruitList, and Volts input arguments. Create a new variable called count and initialize it with 1. Setup a new while statement which runs the same number of elements as in Volts input arguments, for each iteration do the following checks: o Check the current voltage readings is between 5 and 12 (inclusive), save 'M' in the fruitList output argument. o Check the current voltage readings is between 13 and 21 (inclusive), save 'B' in the fruitList output argument. o Check the current voltage readings is between 22 and 33 (inclusive), save 'S' in the fruitList output argument. o Check the current voltage readings is between 34 and 42 (inclusive), save 'C' in the fruitList output argument. o Check the current voltage readings is 42, save 'U' in the fruitList output argument. Update the value of count in every iteration. Sample Run: 18.0 33.0 31.0 34.0 15.0 37.0 10.5 48.0 50.0 38.0 35.0 39.0 42.0 33.0 31.0 1.0 5.0 9.0 13.0 11.0 27.0 35.0 -1.0 46.0 22.0 6.0 19.0 36.0 Output find function Voltage Fruit 18.0 B 33.0 S 31.0 S 34.0 15.0 B 37.0 M 10.5 48.0 U 50.0 U 38.0 35.0 39.0 C 42.0 33.0 S 31.0 S 1.0 U 5.0 M 9.0 M 13.0 B 11.0 M 27.0 S 35.0 -1.0 U 46.0 U 22.0 S 6.0 M 19.0 B 36.0 Output while function Voltage Fruit 18.0 B 33.0 S 31.0 S 34.0 15.0 B 37.0 10.5 M 48.0 U 50.0 U 38.0 35.0 39.0 42.0 33.0 S 31.0 S 1.0 U 5.0 M 9.0 M 13.0 B 11.0 M 27.0 S 35.0 U - 1.0 46.0 U 22.0 S 6.0 M 19.0 B 36.0

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!