Question
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
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 twoinputs,an array for toast thickness and an array for toast area, which collectively represent each slice of the loaf of bread.Your functionshould call your butterbot function from Recitation 3inside of a loop.Do not just rewrite the codefrom that function.In zyLabs, you will have a correct version of howMuchButter to call.For each call to howMuchButter, your functionshould take the output string and convert it to the following numeric code:-1 for a small amount of butter.-2 for a moderate amount of butter-3 for lots of butter-0 for the toast being too weird.These numeric codes should then be storedin an array.You maywant touse 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 theresulting array in descending order.Your function should return twooutputs: -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 figureout 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 sortand lengthare allowed, and may be useful to you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started