Contents
Aaron Klapheck
clear, clc
Date = date
Date =
12-Dec-2007
Problem 2
material = 0.62; energy = 0.24; labor = 0.16; fixed = 2045000;
Q = [0:100:10^7];
Total_cost = fixed + (material+energy+labor)*Q;
Revenue = ((6*10^6 -Q)/(1.1*10^6)).*Q;
plot(Q, Total_cost, Q, Revenue), grid, xlabel('Q'), ...
title('Total Cost and Revenue vs. Sales Quantity'), ...
legend('Cost($) vs. Q(gal)', 'Revenue($) vs. Q(gal)'), ...
ylabel('Cost and Revenue')
Problem 2 - fist break even point (the one on the left)
plot(Q, Total_cost, Q, Revenue), grid, xlabel('Q'), ...
title('Total Cost and Revenue vs. Sales Quantity'), ...
legend('Cost($) vs. Q(gal)', 'Revenue($) vs. Q(gal)'), ...
ylabel('Cost and Revenue'),
axis([5*10^5 5.3*10^5 2.5*10^6 2.6*10^6]), ...
[Q_1, Revenue_1] = ginput(1)
Q_1 =
5.1573e+005
Revenue_1 =
2.5709e+006
Problem 2 - second break even point (the one on the right)
plot(Q, Total_cost, Q, Revenue), grid, xlabel('Q'), ...
title('Total Cost and Revenue vs. Sales Quantity'), ...
legend('Cost($) vs. Q(gal)', 'Revenue($) vs. Q(gal)'), ...
ylabel('Cost and Revenue'),
axis([4.3*10^6 4.4*10^6 6.4*10^6 6.6*10^6]), ...
[Q_2, Revenue_2] = ginput(1)
Q_2 =
4.3623e+006
Revenue_2 =
6.4944e+006
Problem 2 - maximum profit and state range
plot(Q, Total_cost, Q, Revenue), grid, xlabel('Q'), ...
title('Total Cost and Revenue vs. Sales Quantity'), ...
legend('Cost($) vs. Q(gal)', 'Revenue($) vs. Q(gal)'), ...
ylabel('Cost and Revenue'),
axis([2.9*10^6 3.1*10^6 7*10^6 10*10^6]), ...
[Q_max, Revenue_max] = ginput(1)
Range_of_Q_for_profitablility = [Q_1, Q_2]
Q_max =
3.0002e+006
Revenue_max =
8.1798e+006
Range_of_Q_for_profitablility =
1.0e+006 *
0.5157 4.3623
Problem 3
x = [-10:0.01:10];
p = [4, 3, -95, 5, -10, 80];
plot(x, polyval(p,x)), title('Finding Roots of a Polynomial'), grid, ...
xlabel('x'), ylabel('y = 4x^5+3x^4-95x^3+5x^2-10x+8')
Problem 3 - Use plot to find first root
plot(x, polyval(p,x)), title('Finding Roots of a Polynomial'), grid, ...
xlabel('x'), ylabel('y = 4x^5+3x^4-95x^3+5x^2-10x+8'), ...
axis([-5.4 -5.2 -0.1 0.1]), [x1_root, y1] = ginput(1)
x1_root =
-5.3094
y1 =
-2.9240e-004
Problem 3 - Use plot to find second root
plot(x, polyval(p,x)), title('Finding Roots of a Polynomial'), grid, ...
xlabel('x'), ylabel('y = 4x^5+3x^4-95x^3+5x^2-10x+8'), ...
axis([0.8 1 -0.1 0.1]), [x2_root, y2] = ginput(1)
x2_root =
0.9459
y2 =
-8.7719e-004
Problem 3 - Use plot to find third root and double check
plot(x, polyval(p,x)), title('Finding Roots of a Polynomial'), grid, ...
xlabel('x'), ylabel('y = 4x^5+3x^4-95x^3+5x^2-10x+8'), ...
axis([4.4 4.5 -0.1 0.1]), [x3_root, y3] = ginput(1)
Actual_root_of_polynomial = roots(p)
Graphical_root_of_polynomial = [x1_root, x2_root, x3_root]
x3_root =
4.4741
y3 =
-2.9240e-004
Actual_root_of_polynomial =
-5.3094
4.4740
0.9461
-0.4303 + 0.8395i
-0.4303 - 0.8395i
Graphical_root_of_polynomial =
-5.3094 0.9459 4.4741
Problem 6
t = [0:1:100];
V = 10^9 + 10^8*(1 - exp(-t/100)) - 10^7*t;
plot(t, V), axis([0 100 4.9*10^8 5.1*10^8]), ...
Title('Water Volume in Reservoir vs. Time'), ...
xlabel('Time (Days)'), ylabel('Water Volume (Liters)'), grid, ...
[days, liters_of_water] = ginput(1)
Warning: Could not find an exact (case-sensitive) match for 'Title'. C:\MATLAB701\toolbox\matlab\graph2d\title.m is a case-insensitive match and will be used instead. You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly. Alternatively, you can disable this warning using warning('off','MATLAB:dispatcher:InexactMatch').
days =
54.4931
liters_of_water =
4.9991e+008
Problem 9
A = [0, -8, 6; 5, -4, 3; 10, -1, 1; 15, 1, 0; 20, 2, -1]
plot(A(:, 1),A(:, 2:3)), Title('Forces Applied for a Given Time'), ...
xlabel('Time (s)'), ylabel('Force (N)')
A =
0 -8 6
5 -4 3
10 -1 1
15 1 0
20 2 -1
Problem 11
x = [0:0.01:2*pi];
y = tan(2*x);
subplot(1,2,1)
plot(x, y), title('tan(2x) vs. x'), xlabel('x'), ylabel('tan(2x)')
x = [0:0.01:2*pi];
y = (2*tan(x))./(1-tan(x).^2);
subplot(1,2,2)
plot(x, y), title('2tan(x)/(1-tan(x)^2) vs. x'), xlabel('x'), ...
ylabel('2tan(x)/(1-tan(x)^2)')
Problem 14
t = [0:0.01:30];
c = [1:1:20];
y_98 = 0.98
b_1 = c(1);
y_1 = 1 - exp(-b_1.*t);
b_10 = c(10);
y_10 = 1 - exp(-b_10.*t);
b_2 = c(2);
y_2 = 1 - exp(-b_2.*t);
subplot(1,1,1)
plot(t, y_1, t, y_2, t, y_10, t, y_98, '--'), axis([0 6 0 2]), ...
title('(1 - exp(-bt)) vs. t at Various Values of b'), ...
xlabel('Time'), ylabel('1 - exp(-bt)'), grid, ...
legend('1 - exp(-t)', '1 - exp(-10t)', '1 - exp(-20t)', 'y = 0.98')
y_98 =
0.9800
Problem 15
t = [0:0.01:10];
x = 10.*exp((-0.5).*t).*sin(3.*t + 2);
y = 7.*exp((-0.4).*t).*cos(5.*t - 3);
plot(t, x, t, y), xlabel('Time'), ylabel('Oscillations and Vibrations'), ...
title('Electical Oscillations and Machine Vibrations vs. Time'), ...
legend('Electrical Circuit Oscillations', 'Machine Vibrations')