Question: Write a function called MaxRevenueSort ( ) that takes the array clled NumItemsSold as an input. MaxRevenueSort ( ) calculates the revenue made, and sorts

Write a function called MaxRevenueSort() that takes the array clled NumItemsSold as an input. MaxRevenueSort() calculates the revenue made, and sorts the revenue in descending order in an array called sortedRevenue. (Descending order in the array mean the highest revenue value is the (1,1) position in sortedRevenue. The remaining elements descrease in order from left to right on the first row until the last column.)
Hint: The internal functions sort() and reshape() should be used.
Restrictions: Loops should not be used
Ex: Given
numItemsSold =[382943; 243555; 131750];
the output is
sortedRevenue =
275022501290
1225950510
480435260
function sortedRevenue = MaxRevenueSort(numItemsSold)
itemPrice =[251530; 203550; 203045];
% Calculate Revenue
revenue = numItemsSold .* itemPrice
%Sort Revenue in descending order
sortedRevenue = reshape(sort(revenue(:), 'descend'
end

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 Programming Questions!