Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab code Function Name: myCabbages Inputs: 1. ( cell ) An Nx3 cell array of your cabbage cart statistics Outputs: 1. (cell ) An (N+1)x3

Matlab code

Function Name: myCabbages

Inputs:

1. ( cell ) An Nx3 cell array of your cabbage cart statistics

Outputs:

1. (cell ) An (N+1)x3 edited cell array of your cabbage cart statistics

Background:

You love traveling all over the world selling cabbages from your cabbage cart. You journey all the way to the great city of Omashu to sell your spectacular cabbages but get stopped by the guards outside the city's gates because they believe your cabbages are rotten. While you know this is untrue, as you only sell cabbages of the most superior quality, the unappreciative guards throw your entire cabbage cart off a cliff! Oh no! Your cabbages! Distraught, you decide to make a MATLAB function that calculates how much money you lost, so you can sue for damages and be prepared just in case this ever happens again...

Function Description:

Write a function that edits a cell array of your cabbages cart statistics to find how many cabbages and how much money you lost. The cell array will have three columns - the first lists different types of cabbages you sell, the second has how many cabbages of that type you have, and the third has their corresponding price per cabbage. Sort the array by the price per cabbage with the cheapest type of cabbage at the top. Then, calculate the total number of cabbages you had and the total amount of money your cabbages were worth, and concatenate these values to the bottom of the array in that order, with the words 'Total loss' in the first column.

Example:

>> arr = >> out = myCabbages(arr)

Savory 3 1 Savory 3 1
Chinese 5 3 Napa 2 2
Napa 2 2 Chinese 5 3
Total loss 10 22

Notes:

? The columns are guaranteed to be in this specific order.

? Round the total amount of money lost to 2 decimal places.

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

Step: 3

blur-text-image

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

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Stages of a Relationship?

Answered: 1 week ago