MATLAB: How to solve this problem

helphomeworkplotwhile loop

Problem : A marketing engineer at the Acme paint production company is looking to maximize the profitability of the company's efforts by setting the wholesale price on its flagship product "CoatAll" that it sells exclusively to its main distributor Paint-R-Us. Years of experience and modeling has developed an equation that relates the millions of gallons sold Q to the sales price P. That equation is Q = 6 – 1.1 P. So if we give it away we sell 6 million gallons, and if we charge $6 a gallon, no stores will order it. We have fixed costs of $2.045 million per year and variable costs of:
Materials: 62 cents per gallon
Energy: 24 cents per gallon
Labor: 16 cents per gallon
Make a script that generate a vector of the reasonable prices to the nearest cent, computes the net profits, and makes a plot of profit vs. price. The script should automatically add the standard axis labeling, title, name, date, reference info. The script should also scan to get the break-even price points and the max profit price. Edit the plot by clicking the little white arrow icon to add annotation for the break-even & max points and a text box that shows the unique equation and costs data.
The code should include the use of a while loop. I am kinda lost on how to start, but so far I have:
format bank
Price = 0;
Quantity = 1:10;
while Price<6 && Price>0
Price = (6-Quantity)./1.1;
end
I am unsure of how to progress from here, and I am confused about how the table of variable costs would be used.

Best Answer

Here's a start. See if you can fill in the missing parts:
% Loop over every cent from a price of 0 to a price of 6
counter = 1;
% Assign the values from your problem statement.
Materials = 62; % cents per gallon


Energy = 24; % cents per gallon
Labor = 16; % cents per gallon
fixedCosts = 2.045; % million dollars
for P = 0 : 0.01 : 6
Q(counter) = (6 - 1.1 * P) * 1000000; % Gallons - from your problem statement
% Get the total costs. Be careful of units!!!
% Convert everything to gallons and dollars.
totalCosts(counter) = 2.045e6 + ...
(Materials/100) * Q(counter) + ...
(Energy / 100) * Q(counter) + ...
(Labor / 100) * Q(counter);
totalRevenue(counter) = (fill in the blank); % Gallons * ($ per gallon) = $
totalProfit(counter) = (fill in the blank);
counter = counter + 1;
end
% Plot everything so we can visualize what's going on.
P = 0 : 0.01 : 6;
subplot(2, 1, 1);
plot(P, Q, 'b-', 'LineWidth', 2);
xlabel('Selling Price', 'FontSize', 16);
ylabel('Gallons Sold', 'FontSize', 16);
grid on;
% Put a line along the y=0 line

yline(0, 'LineWidth', 2);
subplot(2, 1, 2);
plot(P, totalCosts, 'r-', 'LineWidth', 2);
hold on;
grid on;
plot(P, totalRevenue, 'b-', 'LineWidth', 2);
plot(P, totalProfit, 'g-', 'LineWidth', 2);
xlabel('Selling Price', 'FontSize', 16);
ylabel('$', 'FontSize', 16);
% Put a line along the y=0 line
yline(0, 'LineWidth', 2);
legend('totalCosts', 'totalRevenue', 'totalProfit', 'x axis');
% Find the max
[maxProfit, indexOfMax] = max((fill in the blank))
% Get the quantity
maxQuantity = (fill in the blank)
You should get something like this: