Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. [Submit on zyLabs] Loops are very useful for doing the same calculation over and over, very quickly. In this problem, we have a loaf

image text in transcribed

2. [Submit on zyLabs] Loops are very useful for doing the same calculation over and over, very quickly. In this problem, we have a loaf of bread that has been turned into toast. We need to write program that takes two inputs, an array for toast thickness and an array for toast area, which collectively represent each slice of the loaf of bread. Your function should call your butterbot function from Recitation 3 inside of a loop. Do not just rewrite the code from that function. In zyLabs, you will have a correct version of howMuchButter to call. For each call to howMuchButter, your function should take the output string and convert it to the following numeric code: - for a small amount of butter. 2 for a moderate amount of butter - 3 for lots of butter - O for the toast being too weird. These numeric codes should then be stored in an array. You may want to use the strcmp function, which compares two strings to determine if they are the same. Please search MATLAB help for strcmp. You can also consider using switch/case. After your loop has run, you should sort the resulting array in descending order. Your function should return two outputs: The sorted array The corresponding array of indices that maps the sorted array of butter amounts to the original toast thicknesses and areas. This function should NOT figure out the amount of butter itself. To figure out the amount of butter, it should call your function from Recitation 3 Problem 1. Calling other built in MATLAB functions is also acceptable, and functions, like sort and length are allowed, and may be useful to you. 2. [Submit on zyLabs] Loops are very useful for doing the same calculation over and over, very quickly. In this problem, we have a loaf of bread that has been turned into toast. We need to write program that takes two inputs, an array for toast thickness and an array for toast area, which collectively represent each slice of the loaf of bread. Your function should call your butterbot function from Recitation 3 inside of a loop. Do not just rewrite the code from that function. In zyLabs, you will have a correct version of howMuchButter to call. For each call to howMuchButter, your function should take the output string and convert it to the following numeric code: - for a small amount of butter. 2 for a moderate amount of butter - 3 for lots of butter - O for the toast being too weird. These numeric codes should then be stored in an array. You may want to use the strcmp function, which compares two strings to determine if they are the same. Please search MATLAB help for strcmp. You can also consider using switch/case. After your loop has run, you should sort the resulting array in descending order. Your function should return two outputs: The sorted array The corresponding array of indices that maps the sorted array of butter amounts to the original toast thicknesses and areas. This function should NOT figure out the amount of butter itself. To figure out the amount of butter, it should call your function from Recitation 3 Problem 1. Calling other built in MATLAB functions is also acceptable, and functions, like sort and length are allowed, and may be useful to you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

Students also viewed these Databases questions

Question

Briefly describe the term operations management.

Answered: 1 week ago

Question

On what domain is the function f(x) = r2+52 5 continuous? 3

Answered: 1 week ago

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago