Solutions Manual©

 

to accompany

 

MATLAB for Engineering Applications, Fifth Edition

 

By

 

William J. Palm III

University of Rhode Island

 

Solutions to Problems in Chapter One

 

Word Processors and Solution Files: A Warning

The built-in MATLAB Editor does not recognize symbols that are not on the standard keyboard. So if you cut-and-paste a file from such a processor into the Editor, the Editor may generate an error message if your file contains symbols not found on the standard keyboard. For example, the expression y = -2*x contains a minus sign created with the hyphen symbol, which is not the "true" minus sign created by an equation editor. A "true" minus sign will generate an error message if pasted into the MATLAB Editor, as will many other symbols and Greek letters.

Another source of error is a pair of single quotation characters, such as xlabel('x'). Some word processors will automatically convert such a pair to "smart quotes", as `x´, and this will also generate an error message in the MATLAB Editor. Also,  three periods (. . .) are used to denote line continuation in the MATLAB Editor and some word processors will convert these into a single symbol that is not recognized by the Editor. So, to avoid such errors, use only symbols from the standard keyboard when creating files.

In this solutions manual we have tried to avoid using smart quotes, ellipses, and "true" minus signs in our MATLAB code, so that you may cut-and-paste our code into the MATLAB Editor. If we missed any, please let us know.

 

 

 

 

 

 

 

 

 


 

Test Your Understanding Problems

 

T1.1-1 Depending on what toolboxes you have installed, you should see something like

 

MATLAB                                   Version 9.10        (R2021a)

Simulink                                   Version 10.3        (R2021a)

Control System Toolbox        Version 10.10     (R2021a)

Symbolic Math Toolbox         Version 8.7         (R2021a)

 


 

T1.1-2  a) 6*10/13 + 18/(5*7) + 5*9^2. Answer is 410.1297.

 

b) 6*35^(1/4) + 14^0.35. Answer is 17.1123.

 


 

T1.1-3 Type the expressions given in the problem to obtain  a) 0.04 b) 0.02 c) 0.2 d) 32.

 


 

T1.1-4 The session is:

>>x = -5 +9i; y = 6 - 2i;

>>S = x +y

S =

   1.0000 + 7.0000i

>>P = x*y

P =

 -12.0000 +64.0000i

>>R = x/y

R =

  -1.2000 + 1.1000i

 


 

T1.3-1 The session is:

 

>>x = cos(0):0.02:log10(100);

>>length(x)

ans =

51

>>x(25)

ans =

1.4800

 


 

T1.3-2 The session is:

 

>>roots([1, 6, -11, 290]

ans =

-10.000

2.0000 + 5.0000i

2.0000 - 5.0000i

 

The roots are −10 and 2 ± 5i.

 


 

T1.3-3 The script is:

x = 0:0.01:10;

y = 3*x.^2 + 2;

plot(x,y), xlabel('x'),ylabel('y')

 

Figure for T1.3-3


 

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)')

Figure for T1.3-4


 

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)')

Figure for T1.3-5


 

T1.4-1 The script is:

 

r = input('Enter the sphere radius:');

A = 4*pi*r^2;

disp('The surface area is:')

disp(A)


 

T1.4-2 The script is:

a = input('Enter a: ')

b = input('Enter b: ')

c = sqrt(a^2+b^2)

 


 

T1.5-1 Typing help nthroot returns:

“nthroot(X, N) returns the real Nth root of the elements of X.”

 

“Both X and N must be real, and if X is negative, N must be an odd integer.”


 

T1.5-2 Typing lookfor hyperbolic returns more than 30 functions.


 

T1.5-3 Typing “help why” returns:

“ why    Provides succinct answers to almost any question.”

 

   “ why, by itself, provides a random answer.”

 

    “why(N) provides the N-th answer.”

 

   “ Please embellish or modify this function to suit your own tastes.”

 

 


 

End-of-Chapter Problems

 

1.1   The session is:

 

>>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


 

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

 


 

1.3 The session is:

 

>>x = 5; y = 2;

>>1/(1-1/x^5)

ans =

1.0003

>>3*pi*x^2

ans =

235.6194

>>3*y/(4*x-8)

ans =

0.5000

>>4*(y-5)/(3*x-6)

ans =

-1.3333

 


 

1.4 a) x = 3;y = 6*x^3 + 4/x. The answer is y = 50.

b) x = 7;y = (x/4)*3. The answer is y = 6.7500.

c) x = 9;y = (4*x)^2/25. The answer is y = 40.9600.

d) x = 4;y = 2*sin(x)/5. The answer is y = 0.0564.

e) x = 30;y = 7*x^(1/3) + 4*x^0.58. The answer is y = 41.7340.

 


 

1.5 The session is:

 

>>a = 1.12; b = 2.34; c = 0.72;d = 0.81;f = 19.83;

>>x = 1 + a/b + c/f^2

x =

1.4805

>>s = (b-a)/(d-c)

s =

13.5556

>>r = 1/(1/a + 1/b + 1/c + 1/d)

r =

0.2536

>>y = a*b/c*f^2/2

y =

715.6766

 


 

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;

 

The answers are: a = 225.6717, b = 7.7189, and c = 202.4120.

 


 

1.7  a)  1/16,  16^-1, and  16^(-1) all give the correct answer: 0.0625.

 

b)  16^ (-1/2) gives the correct answer: 0.25.   16^-1/2 is incorrect.

 

c)  16^(-1/2) gives the correct answer: 0.25.

 

d)   64^(3/2) gives the correct answer: 512.   64^3/2 is incorrect.

 


 

1.8  a) 0.01  b) 0.005 c)  0.1  d)  500,000


 

1.9 a) c=8,  overflow b) f = 0, underflow, c) i) x = 8  ii) y = 25, x=7.5


 

1.10 The session is:

>>r = 5; h = 15

>>V = pi*r^2*h;

>>V = 1.2*V;

>>r = (V/(pi*h))^(1/2)

r =  5.4772

 

The required radius is  5.4772.


 

1.11 The session is:

 

>>r = 3;

>>V = 4*pi*r^3/4;

>>V = 1.3*V;

>>r = ((3*V)/(4*pi))^(1/3)

r =

2.9748

 

The required radius is 2.9748.

 


 

1.12 The session is

 

>>x = -7-5i;y = 4+3i;

>>x+y

ans =

-3.0000 - 2.0000i

>>x*y

ans =

-13.0000 -41.0000i

>>x/y

ans =

-1.7200 + 0.0400i

 


 

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

 

 


 

1.14 The session is:

 

>>x = 6+9i;y = -5+4i

>>u = x + y

u =

   1.0000 +13.0000i

>>v = x*y

v =

 -66.0000 -21.0000i

>>w = x/y

w =

   0.1463 - 1.6829i

>>z = exp(x)

z =

  -3.6758e+02 + 1.6626e+02i

>>r = sqrt(y)

r =

   0.8376 + 2.3878i

>>s = x*y^2;

s =

 

   4.1400e+02 - 1.5900e+02i

 

 


 

1.15 The session is:

 

>>n = 1;R = 0.08206;T = 273.2;V=22.41;

>>a = 6.49;b = 0.0562;

>>Pideal = n*R*T/V

Pideal =

1.0004

>>P1 = n*R*T/(V - nb)

P1 =

1.0029

>>P2 = (a*n^2)/V^2

P2 =

0.0129

>>Pwaals = P1 + P2

Pwaals =

1.0158

 

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.

 


 

1.16 The ideal gas law gives

 

Thus   or . The session is:

 

>>V1 = 28500;T1 = 273.2 - 15;T2 = 273.2 + 31;

>>V2 = V1*T2/T1

V2 = 3.3577e+4

 

The volume is 33,577 cubic feet.

 


 

1.17 a)  exp(2) gives 7.3891.

 

b)  log10(2) gives 0.3010.

 

c)  log(2) gives 0.6931.  ln(2) gives "Undefined function or variable 'ln'."

 

d)  600^(1/4) gives the correct answer: 4.9492. 600^1/4 gives 150, which is incorrect.

 


 

1.18 a)  cos(pi/2) gives 6.1232e-17.

 

b)  cosd(80) gives 0.1736.

 

c)  acos(0.7) gives 0.7954.

 


 

1.19 a)  atan(2) gives 1.1071.

 

b)atand(100) gives 89.4271.

 

c)  atan2d(3,2) gives 56.3099 degrees.

 

d)  atan2d(3,-2) gives 123.6901 degrees.

 

e)  atan2d(-3,2) gives -56.3099 degrees.

 

d)  acosd(0.6) gives 53.1301.

 

 


 

1.20 The session is:

 

>>x=1:0.2:5;

>>y = 7*sin(4*x);

>>length(y)

ans =

     21

>>y(3)

ans =

     -4.4189

 

There are 21 elements. The third element is −4.4189.

 


 

1.21 The session is:

 

>>x = sin(-pi/2):0.05:cos(0);

>>length(x)

ans =

41

>>x(10)

ans =

-0.5500

 

There are 41 elements. The tenth element is 0.55.

 

 


 

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);

 

The answers are a = 8.0931, b = 6.0240 × 103, c = 0.3062, and d = −0.0587.

 


 

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.

 


 

1.24 The session is:

 

>>ratio=10^(1.5*6.8)/10^(1.5*5.8)

ratio =

   31.6228

 

The answer is 31.6228 times more energy.

 

 


 

1.25 The session is:

 

>>p = ([13,182,-184,2503];

>>r = roots(p)

r =

-15.6850

0.8425 + 3.4008i

0.8425 - 3.4008i

 

The roots are x = −15.685 and x = 0.8425 ± 3.4008i.

 


 

1.26 The session is:

 

>>p = [60, 20, -15, 30];

>>roots(p)

ans =

  -1.0381 + 0.0000i

   0.3524 + 0.5979i

   0.3524 - 0.5979i

 

The roots are −1.0381 and 0.3524 ± 0.5979i.

 


 

1.27 The session is:

 

>>t = 1:0.005:3;

>>T = 7*log(t) - 8*exp(-0.3*t);

>>plot(t,T),title('Temperature Versus Time'),...

xlabel('Time t (min)'),ylabel('Temperature T ^\circ C)')

Figure for Problem 1.27


 

 

1.28 The session is:

 

>>x = 0:0.01:2;

>>u = 3*log10(70*x+1);

>>v = 4*cos(7*x);

>>plot(x,u,x,v,'--'),ylabel('Speed (mi/hr)'),xlabel('Distance x (mi)')

 

Figure for Problem 1.28


 

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')

 

The plot is shown in the figure.

Figure for Problem 1.29

 

 


 

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’)

 

The plot is shown in the figure.


 

1.31 The script is

 

 v=30; % speed(km/hr)

 T=3; % total time (hr)

 phi =  atan(24/17); % course angle (rad)

 t = 0:0.005:T; % time variable

 x = -5 + (v*cos(phi))*t; % x variable

 y = (24/17)*x + 154/17; % y variable

 theta = atan2d(y,x); % bearing angle

 plot(t,theta), xlabel('t (hr)'),ylabel('theta (deg)')

Figure for Problem 1.31


 

1.32 The answer depends on the user's computer system.

 


 

1.33 Note that

 

Thus . The area is given by

 

which can be solved for L:

 

The perimeter is given by

 

The script file is:

 

W = 8; A = 100;

L = (A - W^2/4)/W

P = 2*L + W + 2*W/sqrt(2)

 

The answers are L = 10.5 meters and the total length is the perimeter P = 40.3137.

meters.

 


 

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 script file is:

 

b1 = 200;b2 = 180;c1 = 120;

A1 = 120*pi/180;A2 = 100*pi/180;

a = sqrt(b1^2 + c1^2 - 2*b1*c1*cos(A1));

roots([1,-2*b2*cos(A2),b2^2-a^2])

 

The two roots are c2 = −247.9984 and c2 = 185.4851. Taking the positive root gives 185 meters.

 


 

1.35 The script is

disp('To compute the roots of x^3+ax^2+bx+c=0, enter a, b, and c.')

a = input('Enter a: ');

b = input('Enter b: ');

c = input('Enter c: ');

roots([1,a,b,c])

 

For example, if a= 23, b = 4, and c = 5, the roots are

-22.8344 + 0.0000i

  -0.0828 + 0.4606i

  -0.0828 - 0.4606i


 

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.

 


 

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.


 

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))”.

 

From Euler’s identity, if z = x + iy, ez = ex (cos y + i sin y).

 


 

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

where v is the initial speed and h is the maximum height. We can solve this for v:

Note that the mass m cancels, so the result is independent of m.

 

For h = 20 feet, we get

 

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

 

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.

 


 

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.