MATLAB For Engineering Applications 4th Ed 2019 Ebook Chap 1 Sol
MATLAB For Engineering Applications 4th Ed 2019 Ebook Chap 1 Sol
to accompany
By
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
Test Your Understanding Problems
T1.1-1 Depending on what toolboxes you have installed, you should see something like
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.1-2 a) 6*10/13 + 18/(5*7) + 5*9^2. Answer is 410.1297.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.1-3 Type the expressions given in the problem to obtain a) 0.04 b) 0.02 c) 0.2 d) 32.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.1-4
x = -5 + 9i; y = 6 - 2i;
S = x + y
P = x*y
R = x/y
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-1 The session is:
>>x = cos(0):0.02:log10(100);
>>length(x)
ans =
51
>>x(25)
ans =
1.4800
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-2 The session is:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-3 The script is:
x = 0:0.01:10;
y = 3*x.^2 + 2;
plot(x,y), xlabel('x'),ylabel('y')
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-4 The session is:
>>t = 0:0.01:5;
>>s = 2*sin(3*t+2) + sqrt(5*t+1);
>>plot(t,s),xlabel(‘Time (sec)’),ylabel(‘Speed (ft/sec)’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-4 The session is:
>>x = 0:0.01:1.5;
>>y = 4*sqrt(6*x+1);
>>z = 5*exp(0.3*x)-2*x;
>>plot(x,y,x,z,’—‘0),xlabel(‘Distance (m)’),ylabel(‘Force (N)’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.3-5 The session is:
>>x = 0:0.01:1.5;
>>y = 4*sqrt(6*x+1);
>>z = 5*exp(0.3*x)-2*x;
>>plot(x,y,x,z,’- -‘),xlabel(‘Distance (m)’),ylabel(‘Force (N)’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.4-1 The script is:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.4-2 The script is:
a = input('Enter a: ')
b = input('Enter b: ')
c = sqrt(a^2+b^2)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.5-1 Typing help nthroot returns:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.5-2 Typing lookfor hyperbolic returns 12 functions.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
T1.5-3 Typing “help why” returns:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
End-of-Chapter Problems
>>x = 10; y = 3;
>>u = x + y
u =
13
>>v = x*y
v =
30
>>w = x/y
w =
3.3333
>>z = sin(x)
z =
-0.5440
>>r = 8*sin(y)
r =
1.1290
>>s = 5*sin(2*y)
s =
-1.3971
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.2. The session is:
>>y*x^3/(x-y)
ans =
-13.3333
>>3*x/(2*y)
ans =
0.6000
>>3*x*y/2
ans =
15
>>x^5/(x^5-1)
ans =
1.0323
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.3. The session is:
>>x = 3; y = 4;
>>1/(1-1/x^5)
ans =
1.0041
>>3*pi*x^2
ans =
84.8230
>>3*y/(4*x-8)
ans =
3
>>4*(y-5)/(3*x-6)
ans =
-1.3333
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.4. a) x = 3;y = 6*x^3 + 4/x. The answer is y = 163.3333.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.5. The session is:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.6. The session is:
>>a = (3/4)*6*7^2+4^5/(7^3-145);
>>b = (48.2*55-9^3)/(53+14^2);
>>c = 27^2/4+319^(4/5)/5+60*14^-3;
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.7. a) 1/16, 16^-1, and 16^(-1) all give the correct answer: 0.0625.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.8. a) 0.01 b) 0.005 c) 0.1 d) 500,000
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
151
1.9. a) c=8, overflow b) f = 0, underflow, c) i) x = 8 ii) y = 25, x =7.5 x 10
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.10. The session is:
>>r = 6; h = 10
>>V = pi*r^2*h;
>>V = 1.3*V;
>>r = (V/(pi*h))^(1/2)
r = 6.8411
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.11. The session is:
>>r = 4;
>>V = 4*pi*r^3/4;
>>V = 1.4*V;
>>r = ((3*V)/(4*pi))^(1/3)
r =
4.0656
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.12. The session is
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.13. The session is:
>>(3+6i)*(-7-9i)
ans =
33.0000 -69.0000i
>>(5+4i)/(5-4i)
ans =
0.2195 + 0.9756i
>>3i/2
ans =
0 + 1.5000i
>>3/2i
ans =
0 - 1.5000i
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.14. The session is:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.15. The session is:
The ideal gas law predicts a pressure of 1.0004 atmospheres, while the van der Waals model
predicts 1.0158 atmospheres. Most of the difference is due to the P2 term, which models
the molecular attractions.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.16. The ideal gas law gives
T P
= = constant
V nR
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.17. a) exp(2) gives 7.3891.
d) 600^(1/4) gives the correct answer: 4.9492. 600^1/4 gives 150, which is incorrect.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.18. a) cos(pi/2) gives 6.1232e-17.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.19. a) atan(2) gives 1.1071.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.20. The session is:
>>x=1:0.2:5;
>>y = 7*sin(4*x);
>>length(y)
ans =
21
>>y(3)
ans =
-4.4189
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.21. The session is:
>>x = sin(-pi/2):0.05:cos(0);
>>length(x)
ans =
41
>>x(10)
ans =
-0.5500
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.22. The session is:
>>a = exp(-2.1^3)+3.47*log10(14)+(287)^(1/4);
>>b = 3.4^7*log10(14)+(287)^(1/4);
>>c = (cos(4.12*pi/6))^2;
>>d = cos((4.12*pi/6)^2);
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.23. The session is:
>>a = 6*pi*atan(12.5)+4;
>>b = 5*tan(3*asin(13/5));
>>c = 5*log(7);
>>d = 5*log10(7);
The results are a = 32.1041, b = 0.0000 − 5.0006i, c = 9.7296, and d = 4.2255. In part (b)
note that complex results are obtained from asin(x) if |x| > 1 and from tan(x) if x is
complex.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.24. The session is:
>>ratio=10^(1.5*7.6)/10^(1.5*5.6)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.25. The session is:
>>p = ([13,182,-184,2503];
>>r = roots(p)
r =
-15.6850
0.8425 + 3.4008i
0.8425 - 3.4008i
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.26. The session is:
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.27. The session is:
>>t = 1:0.005:3;
>>T = 6*log(t) - 7*exp(-0.2*t);
>>plot(t,T),title(‘Temperature Versus Time’),...
xlabel(‘Time t (min)’),ylabel(‘Temperature T ^\circ C)’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.28. The session is:
>>x = 0:0.01:2;
>>u = 2*log10(60*x+1);
>>v = 3*cos(6*x);
>>plot(x,u,x,v,0--0),ylabel(‘Speed (mi/hr)’),xlabel(‘Distance x (mi)’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.29. The session is
>>x1 = [0,pi];
>>x2 = [-pi,0];
>>x = -pi:0.01:pi;
>>f1 = [1,1];
>>f2 = -[1,1];
>>series =
(4/pi)*(sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x)+(1/7)*sin(7*x));
>>plot(x,series,x1,f1,x2,f2),xlabel(‘x’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.30. The session is
>>r = 10;
>>phi = 0:0.01:4*pi;
>>x = r*(phi-sin(phi));
>>y = r*(1-cos(phi));
>>plot(x,y),xlabel(‘x’),ylabel(‘y’)
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.31. The script is
v=20; % speed(km/hr)
T=3; % total time (hr)
phi = atan(11/15); % course angle (rad)
t = 0:0.005:T; % time variable
x = -10 + (v*cos(phi))*t; % x variable
y = (11/15)*x + 43/3; % y variable
theta = atan2d(y,x); % bearing angle
plot(t,theta), xlabel('t (hr)'),ylabel('theta (deg)')
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.32. The answer depends on the user's computer system.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.33. Note that
W 2 = D2 + D2 = 2 D2
W = 6; A = 80;
L = (A - W^2/4)/W
P = 2*L + W + 2*W/sqrt(2)
The answers are L = 11.8333 meters and the total length is the perimeter P = 38.1519
meters.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.34. Applying the law of cosines to the two triangles gives
With the given values we can solve the first equation for a1, then solve the second equation
for c2. The second equation is a quadratic in c2, and can be written as
The two roots are c2 = −228 and c2 = 171. Taking the positive root gives c2 = 171 meters.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.35. The script is
-22.8344 + 0.0000i
-0.0828 + 0.4606i
-0.0828 - 0.4606i
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.36. Typing “help plot” gives the required information. Typing “help label” obtains the
response “label not found”. In this case we need to be more specific, such as by typing
“help xlabel”, because label is not a command or function, or we can type “lookfor label”.
Similarly, typing “help cos” gives the required information, but typing “help cosine” obtains
the response “cosine not found”. Typing “lookfor cosine” directs you to the cos command.
Typing “help :” and “help *” gives the required information.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.37. Typing “help sqrt” produces the response “sqrt(X) is the square root of the elements of X. Complex
results are produced if X is not positive.”
It is suggested to investigate realsqrt(X), which gives the square root of the elements of X. An error is
produced if X is negative.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.38. Typing “help exp” gives the response “exp(X) is the exponential of the elements of X, e to the X. For
complex Z=X+i*Y, exp(Z) = exp(X)*(COS(Y)+i*SIN(Y))”.
z x
From Euler’s identity, if z = x + iy, e = e (cos y + i sin y).
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.39. (a) If we neglect drag, then conservation of mechanical energy states that the kinetic
energy at the time the ball is thrown must equal the potential energy when the ball reaches
the maximum height. Thus
1 2
mv = mgh
2
where v is the initial speed and h is the maximum height. We can solve this for v:
v = 2 gh
Note that the mass m cancels, so the result is independent of m.
Because speed measured in miles per hour is more familiar to most of us, we can convert the answer to
miles per hour as a “reality check” on the answer. The result is v = 35.9(3600)/5280 = 24.5 miles per hour,
which seems reasonable.
(b) The issues here are the manner in which the rod is thrown and the effect of drag on
the rod. If the drag is negligible and if we give the mass center a speed of 35.9 feet/second,
then the mass center of the rod will reach a height of 20 feet. However, if we give the rod
the same kinetic energy, but throw it upward by grasping one end of the rod, then it will
spin and not reach 20 feet. The kinetic energy of the rod is given by
1 2 1
KE = mvmc + I w2
2 2
where vmc is the speed of the rod’s mass center. For the same rotational speed and kinetic
energy, a rod with a larger inertia I will reach a smaller height, because a larger fraction
of its energy is contained in the spinning motion. The inertia I increases with the length
and radius of the rod. In addition, a longer rod will have increased drag, and will thus reach
a height smaller than that predicted using conservation of mechanical energy.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.
1.40. (a) When A = 0, d = L1 + L2. When A = 180, d = L1 − L2. The stroke is the
difference between these two values. Thus the stroke is L1 + L2 − (L1 − L2) = 2L2 and
depends only on L2.
b) The MATLAB session looks like the one shown in the text, except that L1 = 0.6 is
used for the first plot and L1 = 1.4 for the second plot . The plots are shown in the following two
figures. Their general shape is similar, but they are translated vertically relative to one
another.
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the
prior written consent of McGraw-Hill Education.