Professional Documents
Culture Documents
Solved Problems
Solution
Script file:
Command Window:
1
2 Chapter 4: Solved Problems
Solution
Script File:
p=input('Please enter the enter the pressure in units of
millibars: ');
h=round(145366.45*(1-(p/1013.25)^0.190289));
fprintf('The altitude is %4.0f ft.\n',h)
Command Window:
Please enter the enter the pressure in units of
millibars: 394
The altitude is 23915 ft.
Solution
Script File:
R=input('Please enter the radius of the cone: ');
h=input('Please enter the heigh of the cone: ');
Chapter 4: Solved Problems 3
r=round(h*R/(sqrt(R^2+h^2)+R)*10)/10;
fprintf('The radius of the largest sphere that can be
inscribed inside a cone\n')
fprintf('with a base radius of %5.1f in. and heights of
%5.1f in. is: %5.1f in.\n',R,h,r)
Command Window:
Solution
Script File:
th=input('Please enter the half-life of the material (in
years): ');
A0=input('Please enter the current amount of the
material (in lb): ');
t=input('Please enter the number of years from now for
which amount should be calculated: ');
k=log(2)/th;
A=A0*exp(-k*t);
fprintf('The amount of the material after %7.1f years is
%6.3f lb\n',t,A)
4 Chapter 4: Solved Problems
Command Window:
Solution
Script File:
R=14;
h=0:2:14;
V=(R^2*acos((R-h)./R)-(R-h).*sqrt(2*R*h-h.^2))*36/231;
V=round(V*10)/10;
T=[h', V'];
fprintf(' h (in.) V (gallons) \n')
disp(T)
Command Window:
h (in.) V (gallons)
0 0
2.0000 3.0000
4.0000 8.4000
6.0000 15.1000
8.0000 22.6000
10.0000 30.8000
12.0000 39.3000
14.0000 48.0000
Chapter 4: Solved Problems 5
where
Solution
Script File:
q=0:10:90;
a=asind((1+3*cosd(q))./sqrt((1+3*cosd(q)).^2+(3-
3*sind(q)).^2));
F=300*4.5*sind(q)./(3*cosd(a-q));
T=[q', F'];
fprintf(' Theta (deg) F (lb) \n')
disp(T)
Command Window:
7. Write a MATLAB program in a script file that calculate the average and the
standard deviation of a list of grades as well as the number of grades on the
list. The program asks the user (input command) to enter the grades as
elements of a vector. The program then calculates the required quantities
using MATLAB’s built-in functions length, mean, and std. The results
are displayed in the Command Window in the following format:
“There are XX grades.” where XX is the numerical value.
“The average grade is XX.” where XX is the numerical value rounded to the
nearest tenth.
“The standard deviation is XX.” where XX is the numerical value rounded
to the nearest tenth.
Execute the program and enter the following grades: 93, 77, 51, 62, 99, 41,
82, 77, 71, 68, 100, 46, 78, 80 and 83.
Solution
Script File:
Command Window:
Solution
Script File:
k=-log(2)/3.5;
t=[23:-4:3];
A=sum(400*exp(k*t))
Command Window:
A =
400.1059
where P is the initial investment, r is the yearly interest rate in % (e.g., 7.5%
entered as 7.5), and n is the number of times per year that the interest is
compounded. Write a MATLAB program in a script file that calculates V.
When the program is executed it asks the user to enter the amount of the ini-
tial investment, the number of years, the interest rate and the number of
times per year that the interest is compounded. The output is displayed in
the following format: “The value of a $XX investment at a yearly interest
rate of X.X% compounded X times per year, after XX years is
$XXXX.XX”, where XXX stands for the corresponding quantities. Use the
program to determine the value of a $20,000 investment after 18 years if the
yearly interest rate is 3.5% compounded 6 time a year.
Solution
Script File:
P=input('Please enter the amount of the initial
investment($): ');
8 Chapter 4: Solved Problems
Command Window:
Solution
Script File:
x=50:0.1:200;
Chapter 4: Solved Problems 9
L=x+2*sqrt((210-x).^2+80^2);
[Lmin, n]=min(L)
xOfLmin=x(n)
Command Window:
Lmin =
348.56
n =
1139.00
xOfLmin =
163.80
Solution
Script File:
format short g
alt=-500:500:10000;
p=29.921*(1-6.8753e-6*alt);
Tb=49.16*log(p)+44.932;
tbl=[alt' Tb'];
disp(' Boiling')
disp(' Altitude Temperature')
disp(' (ft) (degF)')
disp(tbl)
Command Window:
Boiling
Altitude Temperature
(ft) (degF)
-500 212.17
0 212.01
10 Chapter 4: Solved Problems
500 211.84
1000 211.67
1500 211.5
2000 211.32
2500 211.15
3000 210.98
3500 210.81
4000 210.63
4500 210.46
5000 210.29
5500 210.11
6000 209.93
6500 209.76
7000 209.58
7500 209.4
8000 209.22
8500 209.04
9000 208.87
9500 208.68
10000 208.5
Solution
Script File:
A=600;
a=10:0.1:120;
h=2*A./a;
q=atand(a./(2*h));
H=2+h+2./sind(q);
Chapter 4: Solved Problems 11
B=2*H.*tand(q);
AA=B.*H/2;
[AAmin, i]=min(AA)
amin=a(i)
hmin=h(i)
Command Window:
AAmin =
844.1299
i =
273
amin =
37.2000
hmin =
32.2581
Solution
Script File:
x=20:6:68;
a=atand((8-x*tand(8))./x);
b=atand((30-x*tand(8))./x);
th=b-a;
tbl=[x' th'];
disp(' Distance Angle')
disp(' (ft) (deg)')
disp(tbl)
Command Window:
Distance Angle
(ft) (deg)
20.0000 39.1171
26.0000 35.8893
12 Chapter 4: Solved Problems
32.0000 32.3067
38.0000 28.9775
44.0000 26.0620
50.0000 23.5621
56.0000 21.4299
62.0000 19.6083
68.0000 18.0441
Solution
Script File:
L=144;
a=4:0.01:14;
b=1.9*a;
S=(L-2*(a+b))/4;
D=sqrt((a/2).^2+(b/2).^2);
h=sqrt(S.^2-D.^2);
V=a.*b.*h/3;
[Vmax, i]=max(V)
amax=a(i)
bmax=b(i)
Command Window:
Vmax =
1.2466e+03
i =
734
Chapter 4: Solved Problems 13
amax =
11.3300
bmax =
21.5270
Solution
Script File:
s=10000; vr=8.6; vs=3.9;
x=0:5000;
D=sqrt(3000^2+x.^2);
t=(10000-x)./vr+D./vs;
[tmmin, i]=min(t)
xmin=x(i)
Command Window:
tmmin =
1.8484e+03
i =
1527
xmin =
1526
14 Chapter 4: Solved Problems
Solution
Script File:
load HW4_16_data.txt
F=HW4_16_data(1); w=HW4_16_data(2); d=HW4_16_data(3);
t=HW4_16_data(4);
c=d/w;
segN=F/(t*(w-d));
Kt=3-3.14*c+3.667*c^2-1.527*c^3;
segMax=Kt*segN;
fprintf('The maximum stress in a plate with a width of
%.2f in. \n',w)
fprintf('and thickness of %.4f in. and a hole of %.3f in.
in diameter, \n',t,d)
fprintf('due to a tensile force of %.1f lb is %.1f
psi.\n',F,segMax)
Command Window:
diameter,
due to a tensile force of 8000.0 lb is 80714.4 psi.
Solution
Script File:
format shortg
v=350*5280/3600; h=1500;
t=0:0.5:6;
H=h+v*t*sind(10);
X=v*t*cosd(10);
r=sqrt(H.^2+X.^2);
th=acosd(X./r);
Table=[t' th' r'];
disp(' t(s) th (deg) r(ft)')
disp(Table)
Command Window:
4 42.556 2745.2
4.5 39.885 2964.7
5 37.588 3189.8
5.5 35.595 3419.4
6 33.856 3652.5
Solution
Script file:
clear, clc
C=13.83; Eg=0.67; k=8.62e-5;
T=xlsread('Germanium_data.xlsx');
sigma=exp(C-Eg./(2*k*T));
tbl=[T sigma];
disp(' Intrinsic')
disp(' Temperature Conductivity')
disp(' deg K (ohm-m)^-1')
%can also use disp as shown in problem 11
fprintf(' %4.0f %5.1f\n',tbl')
Excel file:
Chapter 4: Solved Problems 17
Command Window:
Intrinsic
Temperature Conductivity
deg K (ohm-m)^-1
400 61.2
435 133.7
475 283.8
500 427.3
520 576.1
545 811.7
where ρ is the density of the fluid, v, the velocity of the flow, and d and D are
defined in the figure. Write a program in a script file that calculates the pres-
sure drop Δp. When the script file is executed it request the user to input the
density in kg/m3, the velocity in m/s, and values of the non-dimensional
ratio as a vector. The program displays the inputted values of ρ and v
followed by a table with the values of in the first column and the cor-
responding values of Δp in the second column.
Execute the program assuming flow of gasoline ( ρ = 737 kg/m3) at
v = 5 m/s and the following ratios of diameters
.
18 Chapter 4: Solved Problems
Solution
Script file:
clear,clc
ro=input('Enter the density of the fluid in kg/m^3 ');
v=input('Enter the velocity of the fluid in m/s ');
dD=input('Enter values of d/D in a vector ');
Dp=(1-dD.^2).^2*ro*v^2/2;
T=[dD; Dp];
disp(' ')
fprintf('Pressure drop for various values of d/D\n')
fprintf('for fluid with density of % .0f kg/m^3 and
velocity of %.1f m/s\n',ro,v)
fprintf(' d/D Pressure drop (Pa)\n')
fprintf(' %g %g\n',T)
Command Window:
Solution
Script file:
clear, clc
sigma=5.669e-8;
T1=input('Please input the temperature of plate 1 in deg
K: ');
T2=input('Please input the temperature of plate 2 in deg
K: ');
a=input('Please input the radius of plate 1 in m: ');
b=input('Please input the radius of plate 2 in m: ');
c=input('Please input the distance between plate 1 and
plate 2 in m: ');
X=a./c; Y=c/b; Z=1+(1+X.^2).*Y.^2;
F_1_2 = 0.5*(Z-sqrt(Z.^2-4*X.^2.*Y.^2));
q=sigma*pi*b^2*F_1_2*(T1^4-T2^4);
fprintf('\nFor circular plate 1 with radius %i m and
temperature %i',a,T1)
fprintf(' deg K\nand circular plate 2 with radius %i m
and temperature',b)
fprintf(' %i deg K\n',T2)
tbl=[c;q];
20 Chapter 4: Solved Problems
fprintf('\n Radiation\n')
fprintf(' Separation Heat Exchange\n')
fprintf(' (m) (Watts)\n')
fprintf(' %4.1f %6.0f\n',tbl)
Command Window:
21. The equation of a circle in a plane with radius R and a center at point
is given by:
Solution
Script File:
A=input('Please enter the coordinates of the first point
as a vector: ');
B=input('Please enter the coordinates of the first point
as a vector: ');
C=input('Please enter the coordinates of the first point
as a vector: ');
a=[-2*A(1) -2*A(2) 1; -2*B(1) -2*B(2) 1; -2*C(1) -2*C(2)
1]
b=[-(A(1)^2+A(2)^2); -(B(1)^2+B(2)^2); -(C(1)^2+C(2)^2)]
x=a\b
R=sqrt(x(1)^2+x(2)^2-x(3))
Command Window:
a =
-23 -10 1
-6.4 -17.2 1
9 13.6 1
b =
-157.25
-84.2
-66.49
x =
3.8213
-1.3356
-82.717
R =
9.955
,
, ,
, ,
, ,
,
Write the equations in matrix form and use MATLAB to determine the
forces in the members. A positive force means tensile force and a negative
force means compressive force. Display the results in a table where the first
column displays the member number and the second column displays the
corresponding force.
Solution
Script File:
m=1:11;
a=[cosd(50) 1 0 0 0 0 0 0 0 0 0
sind(50) 0 0 0 0 0 0 0 0 0 0
Chapter 4: Solved Problems 23
0 -1 0 0 0 1 0 0 0 0 0
-cosd(50) 0 0 1 cosd(41) 0 0 0 0 0 0
-sind(50) 0 1 0 sind(41) 0 0 0 0 0 0
0 0 0 0 -cosd(41) -1 0 0 0 1 0
0 0 0 0 sind(41) 0 1 0 0 0 0
0 0 0 -1 0 0 0 1 cosd(37) 0 0
0 0 0 0 0 0 -1 0 -sind(37) 0 0
0 0 0 0 0 0 0 0 -cosd(37) -1 0
0 0 0 0 0 0 0 0 sind(37) 0 1];
b=[0; 400; 0; 0; 800; 0; 1200; 0; 0; 4933; 0];
x=a\b;
tbl=[m' x];
disp(' Member Force (lb)')
disp(tbl)
Command Window:
,
Write the equations in matrix form and use MATLAB to determine the
forces in the members. A positive force means tensile force and a negative
force means compressive force. Display the results in a table where the first
column displays the member number and the second column displays the
corresponding force.
Solution
Script File:
m=1:7;
a=[cosd(28.5) 1 0 0 0 0 0
sind(28.5) 0 0 0 0 0 0
-cosd(28.5) 0 -cosd(58.4) 0 cosd(58.4) cosd(28.5) 0
-sind(28.5) 0 -sind(58.4) 0 -sind(58.4) -sind(28.5) 0
0 0 0 -1 -cosd(58.4) 0 1
0 0 0 0 0 sind(28.5) 0
0 0 0 0 0 -cosd(28.5) -1];
b=[3000; -6521; -3000; 0; 0; -7479; 0];
x=a\b;
tbl=[m' x];
disp(' Member Force (lb)')
disp(tbl)
Command Window:
Member Force (lb)
1 -13666
2 15010
3 9397.6
4 10086
5 7039.6
6 -15674
7 13775
Chapter 4: Solved Problems 25
Solution
Script File:
Command Window:
a =
-1.4987
b =
6.4888
c =
-1.5099
d =
5.0544
26 Chapter 4: Solved Problems
Solution
Script File:
A=[(-2.5)^4 (-2.5)^3 (-2.5)^2 -2.5 1
(-1.5)^4 (-1.5)^3 (-1.5)^2 -1.5 1
(-0.5)^4 (-0.5)^3 (-0.5)^2 -0.5 1
1^4 1^3 1^2 1 1
3^4 3^3 3^2 3 1];
B=[-62; -7.2; 8.3; 3.7; 45.7];
x=A\B;
a=x(1)
b=x(2)
c=x(3)
d=x(4)
e=x(5)
Command Window:
a =
-0.057085
b =
3.2926
c =
-4.0056
d =
-3.4976
e =
7.9677
Chapter 4: Solved Problems 27
Solution
Script file:
clear, clc
t=0.2; c=1;
K=t*c/0.2;
x=[0.15 0.35 0.5 0.7 0.85];
Command Window:
coefficients =
0.29688
-0.12581
-0.35257
0.28606
-0.10251
28 Chapter 4: Solved Problems
27. During a golf match, a certain number of points are awarded for each eagle
and a different number for each birdie. No points are awarded for par, and
a certain number of points are deducted for each bogey and a different
number deducted for each double bogey (or worse). The newspaper report
of an important match neglected to mention what these point values were,
but did provide the following table of the results:
From the information in the table write four equations in terms of four
unknowns. Solve the equations for the unknown points awarded for eagles
and birdies and points deducted for bogeys and double bogeys.
Solution
Script file:
clear, clc
A=[1 2 1 1
2 3 0 1
1 4 1 0
1 3 2 0];
B=[5; 12; 11; 8];
Points=A\B
Command Window:
Points =
4.0000
2.0000
-1.0000
-2.0000
>>
Chapter 4: Solved Problems 29
28. The dissolution of copper sulfide in aqueous nitric acid is described by the
following chemical equation:
Solution
Script file:
A=[1 0 0 -1 0 0 0
1 0 0 0 -1 0 0
0 1 0 0 0 -1 0
0 3 0 0 -4 -1 -1
0 0 1 0 0 0 -2
0 -1 1 -2 2 0 0
1 0 0 0 0 0 0]
B=[0; 0; 0; 0; 0; 0; 1] % guessing a=1
Solution1=A\B
B=[0; 0; 0; 0; 0; 0; 2] % guessing a=2
30 Chapter 4: Solved Problems
Solution2=A\B
B=[0; 0; 0; 0; 0; 0; 3] % guessing a=3
Solution3=A\B
Command Window:
A =
1 0 0 -1 0 0 0
1 0 0 0 -1 0 0
0 1 0 0 0 -1 0
0 3 0 0 -4 -1 -1
0 0 1 0 0 0 -2
0 -1 1 -2 2 0 0
1 0 0 0 0 0 0
B =
0
0
0
0
0
0
1
Solution1 =
1.0000
2.6667
2.6667
1.0000
1.0000
2.6667
1.3333
B =
0
0
0
0
0
0
2
Solution2 =
2.0000
5.3333
5.3333
2.0000
2.0000
5.3333
Chapter 4: Solved Problems 31
2.6667
B =
0
0
0
0
0
0
3
Solution3 =
3.0000
8.0000
8.0000
3.0000
3.0000
8.0000
4.0000
Answer: a = 3, b = 8, c = 8, d = 3, e = 3, f = 8, g = 4
32 Chapter 4: Solved Problems
29. The Heat Index HI, Calculated from the air temperature and relative
humidity, is the apparent temperature felt by the body. An equation used by
the National Weather Service for calculating the HI is given by:
Solution
Script file:
clear, clc
Ts=80:2:94;
T=[Ts;Ts;Ts;Ts;Ts;Ts];
RH=[50:5:75]';
R=[RH RH RH RH RH RH RH RH];
A=-42.379; B=2.04901523;C=10.1433127;D=-0.22475541;
E=-6.83783E-3;F=-5.481717E-2;G=1.22874E-3; H=8.5282E-4;
I=-1.99E-6;
HIT=round(A+B*T+C*R+D*T.*R+E*T.^2+F*R.^2+G*T.^2.*R+H*T.*
R.^2+I*T.^2.*R.^2);
disp(' Temperature (F)')
fprintf(' ')
fprintf(' %3.0f',Ts)
fprintf('\n Relative\n Humidity\n (%%)\n')
Table=[RH HIT]';
Chapter 4: Solved Problems 33
%fprintf(' %3.0f\n',Table)
%disp(Table)
fprintf(' %6.0f %5.0f %6.0f %6.0f %6.0f %6.0f %6.0f
%6.0f %6.0f\n',Table)
Write a script file that will print out a table of values with
the ratio a/b in the first column and the corresponding
parameter C in the second column. let a/b range between
0.05 and 0.80 with increments of 0.05.
Solution
Script File:
ab=0.05:0.05:0.8;
C=(1-ab/2+0.326*ab.^2)./sqrt(1-ab);
tbl=[ab' C'];
disp(' a/b C')
disp(tbl)
Command Window:
a/b C
0.05 1.0012
0.1 1.0048
0.15 1.0113
0.2 1.0208
0.25 1.0339
0.3 1.051
0.35 1.0728
0.4 1.1001
0.45 1.134
0.5 1.1759
34 Chapter 4: Solved Problems
0.55 1.2278
0.6 1.2924
0.65 1.3738
0.7 1.4784
0.75 1.6168
0.8 1.8082