1 / 6100%
1
ENGR 133, Lab-03
Authored By: Yazan Abbasi
Authored on: 9/25/21
Exercise #1... Problem 5.1
Problem Statement
We are asked to construct a breakeven plot for producing and selling a chemical product. We are given vlaues
for fixed cost (FC), variable cost (VC), quantity (Q), and unit selling price (P). We want to know the breakever
point, the range of profitable production, and the quantity of product that produces maximum profit.
Pseudocode
Initialize variables
Preform calculations
Evaluate results
Display results
Problem Solution
Initialize variables
Preform calculations
Evaluate results
Display results
clc,clear,close all
FC = 3e6; % fixed cost in dollars per year
VC = 0.025; % variable cost in dollars per gallon produced
P = 0.055; % selling price in dollars per gallon sold
Q = [0:200]*1e+6; % quantity produced/sold in millions of gallons per year
TC = FC + Q*VC; % returns total cost (TC) per year in $M
TR = Q*P; % returns total revenue (TR) per year in $M
TP = TR - TC; % returns profit per year in $M
idx = find(TP>0); % finding all positive indexes where TP is positive
minQ_idx = min(idx); % findinf first index where TP is positive
BEP = Q(minQ_idx); % return breakeven point in m illions of gallons per year
plot(Q*1e-6, TC, Q*1e-6, TR, '--')
title('production Economic Model')
xlabel('Quantity Produced/Sold, millions of gallons')
ylabel('Total revenue/cost, $M')
legend('Total Cost', 'Total Revenue', 'location', 'northwest')
grid on
2
The breakeven point occurs at 101 million gallons.
Operations are profitable above this point.
there is no upper limit on profitability.
Exercise #2... Subplots
Problem Statement
We are asked to construct a 2 by 2 grid of plots showing sin(x), cos(x), e^x, and both sin(x) and cos(x) on the
same subplot. We must include elementsto to create proper plots.
Pseudocode
Initialize variables
Display results
Problem Solution
Initialize variables
fprintf('Operations are profitable above this point. \n\n')
fprintf('The breakeven point occurs at %3.0f million gallons. \n\n', BEP*1e-6)
fprintf('there is no upper limit on profitability. \n\n')
clc,clear,close all
3
Display results
Exercise #3... 3-D Plots
Problem Statement
Create a plot of the function: z = (x-2)^2 + 2xy + y^2 that shows amesh plot on top, followed by a contour plot
and a mesh plot with acontour plot on the bottom.
Pseudocode
x = linspace(0,2*pi,1000); % creating an array of 1000 equally spaced points
sin_x = sin(x); % creating an array of sine values
cos_x = cos(x); % creating an array of cosine values
exp_x = exp(x); % creating an array of exponential values
subplot(2,2,1)
plot(x,sin_x), title('f(x) = sin(x)'), grid minor
xlabel('Angle of radians'), ylabel('sin(x)')
subplot(2,2,2)
plot(x,cos_x), title('f(x) = cos(x)'), grid minor
xlabel('Angle of radians'), ylabel('cos(x)')
subplot(2,2,3)
plot(x,exp_x), title('f(x) = e^x'), grid minor
xlabel('x'), ylabel('e^x')
subplot(2,2,4)
plot(x,sin_x,x,cos_x,'--'), title('f(x) = sin(x), cos(x)'), grid minor
xlabel('x'), ylabel('f(x)'), legend('sin(x)', 'cos(x)')
4
Initialize variables
Display results
Problem Solution
Initialize variables
Display results
clc,clear,close all
[X,Y] = meshgrid(-5:0.5:5); % defining the xy grid of interest
z = (X-2).^2 + 2*X.*Y + Y.^2; % defining the z = f(x,y) array
mesh(X,Y,z), xlabel('x'), ylabel('y'), zlabel('z')
title('Mesh plot of z = (x-2)^2 + 2xy + y^2')
figure
contour(X,Y,z), xlabel('x'), ylabel('y'), zlabel('z')
title('Contour plot of z = (x-2)^2 + 2xy + y^2')
5
figure
meshc(X,Y,z), xlabel('x'), ylabel('y'), zlabel('z')
title('Mesh plot with contours of z = (x-2)^2 + 2xy + y^2')
6
Students also viewed