Solution Manual MATLAB For Engineers 6th Edition by Moore
Solution Manual MATLAB For Engineers 6th Edition by Moore
com
WhatsApp: https://wa.me/message/2H3BV2L5TTSUF1 Telegram: https://t.me/solutionmanual
You can either solve these problems in the command window, using MATLAB® as an electronic
calculator, or you can create a program using a script (M-file) or a live script (MLX-file). If you are
solving these problems as a homework assignment or if you want to keep a record of your work, the
best strategy is to use a program file, divided into sections with section dividers.
clear, clc
Getting Started
Problem 2.1
Predict the outcome of the following MATLAB® calculations. Check your results by entering the
calculations into the command window.
1 + 3/4
ans = 1.75
5*6*4/2
ans = 60
5/2*6*4
ans = 60
5^2*3
ans = 75
5^(2*3)
ans = 15625
1 + 3 + 5/5 + 3 + 1
ans = 9
(1 + 3 + 5)/(5 + 3 + 1)
ans = 1
Using Variables
The function isvarname returns a 1 if the name is valid and a 0 if it is not. Although it is possible
to reassign a function name as a variable name, doing so is not a good idea. Use which to check
whether the preceding names are function names—for example,
iioonn
which sin
In what case would MATLAB® tell you that sin is a variable name, not a function name?
The legitimate Matlab names are: fred book_1 Second_Place No_1 vel_5 tan
9911
isvarname fred
ans = logical
1
5599
isvarname book_1
ans = logical
1
isvarname Second_Place
@@
ans = logical
1
isvarname No_1
ggm
ans = logical
1
maa
isvarname vel_5
ans = logical
1
ans = logical
1
ans = logical
0
m
ans = logical
0
ans = logical
0
ans = logical
0
ans = logical
0
ans = logical
0
For example:
sin = 3
sin = 3
which sin
sin is a variable.
built-in (C:\Progr
ram Files\MAT
TLAB\R2022a\
\toolbox\matl
lab\elfun\@d
double\sin) % double me
ethod
lluutt
Scalarr Operatio
ons and Order off Operatio
ons
Proble
em 2.3
Create MATLAB® cod de to perform
m the followin
ng calculation
ns. Check yo our code by e
entering it intto
iioonn
MATLAB® ® and perforrming the calculations on your scientiffic calculator.
5^2
ans = 25
(5 + 3)/(5*6)
9911
ans = 0.2666
67
sqrt(4
4 + 6^3) % or...
ans = 14.83
32
5599
(4 + 6^3)^(1/2)
6
ans = 14.83
32
9+6/12
2 + 7*5^(3+
+2)
@@
ans = 2188
84
1 + 5*3/6^2 + 2^
^(2-4) *1/5
5.5
ggm
ans = 1.462
21
Proble
em 2.4
maa
iill..cc
oom
m
r = 5
r = 5
area = pi*r^2
area = 78.
.54
r = 10
0
r = 10
surface_area = 4*pi*r^2
4
surface_area = 1256.6
r = 2
r = 2
volume
e = 4/3*pi*
*r^3
volume = 33.51
3
Proble
em 2.5
edge = 5
lluutt
edge = 5
area = edge^2
area = 25
iioonn
(b) The surface area of a cube is 6 times
s the edge len
ngth squared
d
edge = 10
9911
edge = 10
surface_area = 6*edge^2
6
surface_area = 600
5599
(c) The volume of a cube is the edge len
ngth cubed ( ). Find the volu
ume of a cub
be
with edge
e length 12.
edge = 12
@@
edge = 12
volume
e = edge^3
volume = 1728
1
ggm
Proble
em 2.6
maa
iill..cc
r=10; %cm
length=15; %cm
d=1; % cm
% Find the volume of each sphere
volume_sphere=4/3*pi*r^3;
% Find the volume of the bar
volume_bar=pi*(d/2)^2*length;
% Combine the components to get the total volume
total_volume=2*volume_sphere +volume_bar
total_volume = 8389.4
b)Surface Area
(b) Find the surface area of the figure.
sa_sphere=4*pi*r^2;
% Find the surface area of the bar
sa_bar=pi*d*length;
% Combine the components to get the total surface area
total_sa=2*sa_sphere + sa_bar
total_sa = 2560.4
Problem 2.7
The ideal gas law was introduced in Example 2.1. It describes the relationship between pressure (P),
temperature (T), volume (V), and the number of moles of gas (n).
PV = nRT
The additional symbol, R, represents the ideal gas constant. The ideal gas law is a good
approximation of the behavior of gases when the pressure is low and the temperature is high. (What
constitutes low pressure and high temperature varies with different gases.) In 1873, Johannes
Diderik van der Waals, (see Figure P2.7) proposed a modified version of the ideal gas law that better
models the behavior of real gases over a wider range of temperature and pressure.
ssoo
lluutt
iioonn
9911
In this equation the ad
dditional varia
ables a and b represent vvalues chara
acteristic of in
ndividual gasses.
R=0.08
8314472; % ideal gas constant L bar/(K mo
ole)
@
T_ideal=P*V/(n*R
R) % kelvi
ins
ggm
T_ideal = 1323
T_VW=(P + n^2*a/
/V^2)*(V - n*b)/(n*R)
)
T_VW = 1367
7.4
iill..cc
oom
m
Proble
em 2.8
h = [1
1, 5, 12]
Find th
he volume off the cylinderrs (see Figure
e P2.8a).
r=3;
h=[1,5,12];
volume
e = pi*r^2.*h
volume = 1×3
28.274 141.37 339.29
3
b = [2, 4, 6]
b=[ 2, 4, 6];
h=12;
area=1
1/2*b.*h
area = 1×3
12 24 36
Although you don't ha ave to use thee .* operator for both mul tiplications a
and the ./ for the division iit
won't hurrt if you do an
nd is good prractice.
area=1
1./2.*b.*h
area = 1×3
12 24 36
ssoo
(c) The volume of anyy right prism is the area of
o the base off the prism, tiimes the verttical dimension of
the prism
m. The base of
o the prism can
c be any sh hape—for exxample, a circcle, a rectang gle, or a trian
ngle.
Find the volume
v of the
e prisms creaated from thee triangles off part (b). Asssume that the
e vertical
dimension of these prrisms is 6
lluutt
iioonn
9911
h=6;
volume
e=h.*area
volume = 1×3
5599
72 144 216
Proble
em 2.9
The respo onse of circu
uits containing
g resistors, in
nductors andd capacitors d
depends upo on the relativve
values of the resistors s and the wayy they are coonnected. Ann important in
ntermediate qquantity used d in
@
The equa
ation that iden
ntifies the res
sponse of a particular
p serries circuit (F
Figure P2.9) is
oom
m
(a) Determine the values of s for a resistance of 800 Ω.
R=800 %ohms
R = 800
L=100e-3 %H
L = 0.1
C=1e-6 %F
C = 1e-06
s = -1550.5
s = 1×2
-1550.5 -6449.5
(b) Create a vector of values for R ranging from 100 to 1000 Ω and evaluate s. Refine your values of
R until you find the approximate size of resistor that yields a pure real value of s. Describe the effect
on s as R increases in value.
Hint:
1 μF = 1e-6 F
1 mH = 1e-3 H
results = [R',s_plus',s_minus']
s_minus = -R./(2
2*L)-sqrt((
(R./(2*L)).
.^2 - 1/(L*
*C))
table_
_values = 11×
×3 complex
600 + 0i -3000 - 0i ⋯
1000
610 + 0i -3050 - 835.16
6i
620 + 0i -3100 - 624.5
5i
5599
630 + 0i -3150 - 278.39
9i
640 + 0i -2710.1
- + 0
0i
650 + 0i -2500 + 0
0i
660 + 0i -2356.6
- + 0
0i
670 + 0i -2244.3
- + 0
0i
680 + 0i -2151 + 0
0i
@
690 + 0i -2070.7
- + 0
0i
@
Proble
em 2.10
The equa
ation that iden
ntifies the res
sponse parameter, s, of tthe parallel ccircuit shown in Figure P2
2.10
ggm
maa
iill..cc
is
oom
m
(a) Determine th ance of 200 Ω.
he values of s for a resista
R=200;
C=1e-6
6;
L=0.64
4
L = 0.64
s_plus=-1/(2*R*C
C) + sqrt((
(1/(2*R*C))
)^2 - 1/(L*
*C))
s_plus = -33
34.94
s_minus=-1/(2*R*
*C) - sqrt(
((1/(2*R*C)
))^2 - 1/(L
L*C))
s_minus = -4
4665.1
R=100:100:1000;
s_plus=-1./(2*R*
*C) + sqrt(
((1./(2*R*C
C)).^2 - 1/
/(L*C));
s_minus=-1./(2*R
R*C) - sqrt
t((1./(2*R*
*C)).^2 - 1
1/(L*C));
results = [R',s_
_plus',s_mi
inus']
R=400:10:500;
s_plus=-1./(2*R*
*C) + sqrt(
((1./(2*R*C
C)).^2 - 1/
/(L*C));
s_minus=-1./(2*R
R*C) - sqrt
t((1./(2*R*
*C)).^2 - 1
1/(L*C));
results = [R',s_
_plus',s_mi
inus']
Proble
em 2.11
iioonn
Burning one
o gallon of gasoline in your
y car prod
duces 19.4 p ounds of CO
O2. Calculate e the amount of
CO2 emittted during a year for the following vehicles, assum
ming they all travel 12,000 miles per yyear.
The reported fuel-effic
ciency numbeers were extracted from tthe U.S. Deppartment of EEnergy website,
www.fueleconomy.gov, and reflect the combined city and h highway estim
mates.
Create an
n array of mp
pg values
9911
mpg=[1
142, 36, 52
2, 35, 41,1
113];
Calculate
e the emissions
5599
Mass_C
CO2=(12000./mpg*19.4)
)'
Mass_CO2 = 6×1
1639.4
6466.7
4476.9
@
6651.4
@
5678
2060.2
Notice tha
at the result was
w transpos
sed so that itt is easier to read.
ggm
Proble
em 2.12
(a) Creatte an evenly spaced vector of values from 1 to 20 in incrementts of 1.
maa
a=1:20
0
a = 1×20
1 2 3 4 5 6 7 8 9 10 11 12
2
13 ⋯
iill..cc
b=0:pi/10:2*pi
oom
b = 1×21
m
0 0.31416 0.
.62832 0.94248 1.2566
1.5708 ⋯
c=linspace(4,20,15)
c = 1×15
4 5.1429 6.2857
6 7.4286 8.5714
9.7143 ⋯
d=logspace(1,3,4
4)
d = 1×4
10 46.416 215.44
2 1000
Proble
em 2.13
(a) Creatte a table of conversions from feet to meters. Starrt the feet column at 0, inccrement it byy 1,
and end iti at 10 feet. (Look
( up the conversion factor
f in a te
extbook or onnline.)
feet=0
0:1:10;
meters=feet./3.2
28;
[feet',meters']
ans = 11×2
0 0
1 0.30488
2 0.60976
3 0.91463
4 1.2195
5 1.5244
6 1.8293
7 2.1341
8 2.439
9 2.7439
⋮
radians=0:0.1*pi
i:pi;
degree
es=radians*
*180/pi;
[radians',degree
es'] % Or we could also
a give t
this array a name
ans = 11×2
0 0
ssoo
0.31416 18
0.62832 36
0.94248 54
1.2566 72
1.5708 90
lluutt
1.885 108
2.1991 126
2.5133 144
2.8274 162
⋮
iioonn
conversion_table=[radians',degrees']
conversion_table = 11×2
0 0
0.31416 18
0.62832 36
0.94248 54
1.2566 72
9911
1.5708 90
1.885 108
2.1991 126
2.5133 144
2.8274 162
⋮
5599
(c) Create a table of conversions from mi/h to ft/s. Start the mi/h column at 0 and end it at 100
mi/h. Print 15 values in your table. (Look up the conversion factor in a textbook or online.)
mph=linspace(0,100,15);
@
ft_per_sec=mph*5280/3600;
@
vel_conversion=[mph',ft_per_sec']
vel_conversion = 15×2
0 0
7.1429 10.476
ggm
14.286 20.952
21.429 31.429
28.571 41.905
35.714 52.381
maa
42.857 62.857
50 73.333
57.143 83.81
64.286 94.286
⋮
(d) The acidity of solutions is generally measured in terms of pH. The pH of a solution is defined
iill..cc
as –log10 of the concentration of hydronium ions. Create a table of conversions from concentration
of hydronium ion to pH, spaced logarithmically from .001 to .1 mol/liter with 10 values. Assuming that
you have named the concentration of hydronium ions H_conc, the syntax for calculating the negative
of the logarithm of the concentration (and thus the pH) is
pH = –log10(H_conc)
oom
m
%d
H_conc=logspace(-3,-1,10);
pH=-lo
og10(H_conc
c);
pH_tab
ble=[H_conc
c',pH']
pH_table = 10×2
0.001 3
0.0016681 2.7778
0.0027826 2.5556
0.0046416 2.3333
0.0077426 2.1111
0.012915 1.8889
0.021544 1.6667
0.035938 1.4444
0.059948 1.2222
0.1 1
Proble
em 2.14
The gene
eral equation for the distance that a fre
eely falling bo
ody has traveled (neglecting air frictio
on) is
g=9.8;
t=0:10
0:100;
d=1/2*g*t.^2;
results=[t',d']
table_
_values = 11×
×2
0 0
10 490
20 1960
30 4410
40 7840
50 12250
60 17640
70 24010
80 31360
90 39690
⋮
Proble
em 2.15
In direct current
c applic
cations, electtrical power is
i calculated using Joule’’s law as
P = VI
ssoo
where P is pow
wer in watts
V is the potential
p diffe
erence, meas
sured in voltss
V = IR
to give
g
iioonn
where R is resis
stance meas
sured in ohms
s.
where
5599
ρ is the ele
ectrical resistiivity measure
ed in ohm-me
eters
l is the leng
gth of the wirre
A is the cro
oss-sectional area of the wire
w
@
Ele
ectrical resisttivity is a matterial property
y that has be
een tabulated
d for many m
materials. Forr
example
maa
iill..cc
Calculate
e the power th
hat is dissipa
ated through a wire with t he following dimensions for each of th
he
materials listed.
diameter 0.001 m
oom
m
length 2.00 m
d=0.001; % meters
area = pi*d^2/4; % meters^2
length = 2; % meters
I=120; %amps
P=I.^2.*rho.*length./area
P = 5×1
583.04
616.04
894.73
1034.1
3666.9
Problem 2.16
Repeat the previous problem for 10 wire lengths, from 1 m to 1 km. Use logarithmic spacing.
length=logspace(1,3,10) % meters
length = 1×10
10 16.681 27.826 46.416 77.426
129.15 ⋯
P_silver=I.^2.*rho(1).*length./area
P_silver = 1×10
2915.2 4862.9 8111.7 13531 22571
37651 ⋯
P_copper=I.^2.*rho(2).*length./area
P_copper = 1×10
3080.2 5138.1 8570.9 14297 23849
39783 ⋯
P_gold = I.^2.*rho(3).*length./area
P_gold = 1×10
4473.7 7462.5 12448 20765 34638
57779 ⋯
P_al = I.^2.*rho(4).*length./area
P_al = 1×10
ssoo
5170.4 8624.7 14387 23999 40032
66778 ⋯
P_Fe = I.^2.*rho
o(5).*lengt
th./area
lluutt
P_Fe = 1×10
18335 30584 51017 85102 1.4196e+05
2.368e+05 ⋯
In chapte
er 4 we'll learn
n how to do these
t calcula
ations in a sin
ngle step usiing the meshg
grid function
n.
iioonn
Proble
em 2.17
Newton’s
s law of unive
ersal gravitatiion tells us th
hat the force exerted by o
one particle o
on another is
9911
where the
e universal gravitational constant
c G is
s found experrimentally to be
G = 6.673
3× N m2/kg2
m
Thee mass of ea
ach particle is
s m1and m2,, respectivelyy, and r is thee distance be
etween the twwo
5599
particles. Use Newtonn’s law of universal gravita
ation to find tthe force exe
erted by the e
earth on the
moon, as ssuming that
the mass of
o the earth is
s approximate
ely 6 × kkg,
@
the mass of
o the moon is
s approximattely 7.4 × kg, and
@
G=6.67
73e-11; % N m^2/kg^
^2
ggm
m_earth=6e24; % kg
m_moon=7.4e22; % kg
r=3.9e
e8; % meter
rs
maa
F=G*m_
_earth*m_mo
oon/r^2
F = 1.9479e+20
Proble
em 2.18
We knoww that the eartth and the moon are not always
a the s ame distance apart. Base ed on the
equation in the previo
ous problem, find the force
e the moon eexerts on the
e earth for 100 distances
between 3.8 × m and 4.0 × m. Be careeful when youu do the divission to use th
he correct
oom
operator.
m
r=linspace(3.8e8
8,4.0e8,10)
); % meters
s
F=G*m_
_earth*m_mo
oon./r.^2; % Notice the .^ and
d ./ operat
tors
[r',F']
ans = 10×2
3.8e+08 2.0518e+20
3.8222e+08 2.028e+20
3.8444e+08 2.0046e+20
3.8667e+08 1.9817e+20
3.8889e+08 1.9591e+20
3.9111e+08 1.9369e+20
3.9333e+08 1.9151e+20
3.9556e+08 1.8936e+20
3.9778e+08 1.8725e+20
4e+08 1.8518e+20
Proble
em 2.19
Recall fro
om Problem 2.7
2 that the id
deal gas law is:
PV =nRT
T
a)
P=linspace(0,400
0,10); % pr
ressure
n=2; % moles
V=1; % volume
a=5.536; % const
tant
b=0.03049; % con
nstant
R=0.08
8314472; % ideal gas constant
T_ideal=P*V/(n*R
R)
T_ideal = 1×10
0 267.27 534.54
5 801.81 1069.1
1336.4 ⋯
T_VW = 1×10
125.04 376.02 626.99 877.97 1128.9
1379.9 ⋯
lluutt
It would be easier to compare the calculated values if they are listed in a table
[T_ideal',T_VW']
iioonn
ans = 10×2
0 125.04
267.27 376.02
534.54 626.99
801.81 877.97
1069.1 1128.9
1336.4 1379.9
9911
1603.6 1630.9
1870.9 1881.9
2138.2 2132.8
2405.4 2383.8
V=linspace(0.1,10,10);
P=220;
% Find the temperature using the ideal gas law
T_ideal=P*V/(n*R)
@@
T_ideal = 1×10
132.3 1587.6 3042.9 4498.2 5953.5
7408.8 ⋯
ggm
T_VW = 1×10
maa
ans = 10×2
132.3 571.23
1587.6 1612.2
3042.9 3018.6
4498.2 4456
5953.5 5902
oom
7408.8 7351.6
m
8864.1 8803.1
10319 10256
11775 11709
13230 13163
c
You might interpret this probem to mean that the 10 values of pressure
V=linspace(0.1,10,10);
P=linspace(0,400,10);
% Find the temperature using the ideal gas law
T_ideal=P.*V/(n*R)
T_ideal = 1×10
0 320.73 1229.4 2726.2 4810.9
7483.6 ⋯
T_VW = 1×10
519.61 409.76 1253.2 2715.7 4774.9
7425.6 ⋯
ans = 10×2
0 519.61
320.73 409.76
1229.4 1253.2
2726.2 2715.7
4810.9 4774.9
7483.6 7425.6
10744 10666
14593 14496
19030 18914
24054 23921
Number Display
Problem 2.20
Create a array a equal to [−1/3, 0, 1/3, 2/3], and use each of the built-in format options to display the
results:
format long
ssoo
format bank
format short e
format long e
lluutt
format short eng
format +
format rat
9911
a=[-1/3,0,1/3,2/3] % displays as format shortg automatically since shortg was
specified at the beginning of this file
a = 1×4
-0.33333 0 0.33333 0.66667
5599
format long
a
a = 1×4
0.333333333333333 ⋯
@
-0.333333333333333 0
@
format bank
a
a = 1×4
ggm
format short e
maa
a = 1×4
-3.3333e-01 0 3.3333e-01 6.6667e-01
format long e
a
iill..cc
a = 1×4
-3.333333333333333e-01 0
3.333333333333333e-01 ⋯
a
m
a = 1×4
-333.3333e-003 0.0000e+000 333.3333e-003 666.6667e-003
a = 1×4
-333.333333333333e-003 0.00000000000000e+000 333.333333333333e-003
⋯
format short
a
a = 1×4
-0.3333 0 0.3333 0.6667
format long g
a
a = 1×4
-0.333333333333333 0
0.333333333333333 ⋯
format +
a
a = 1×4
- ++
format rat
a
a = 1×4
-0.33333 0 0.33333 0.66667
• Once the file is saved, clear your workspace then load the data from the file back into MATLAB.
D=0:10:180;
ssoo
R=D*pi/180;
D_to_R=[D',R']
D_to_R = 19×2
lluutt
0 0
10 0.17453
20 0.34907
30 0.5236
40 0.69813
iioonn
50 0.87266
60 1.0472
70 1.2217
80 1.3963
90 1.5708
9911
save degrees.dat -ascii D_to_R
Check your current directory to confirm that the file was saved
5599
clear
load degrees.dat
degrees
degrees = 19×2
0 0
@@
10 0.17453
20 0.34907
30 0.5236
40 0.69813
ggm
50 0.87266
60 1.0472
70 1.2217
80 1.3963
maa
90 1.5708
iill..cc
oom
m