Instructor's Manualc с to accompany Introduction to Matlab 6 for ...

24 downloads 358 Views 130KB Size Report
Introduction to Matlab 6 for Engineers by ... T1.1-1 a) 6*10/13 + 18/(5*7) + 5*9^2. ... 6. 7. Time t (sec). Speed s (ft/sec). Figure : for Problem T1.3-5. T1.3-6 The ...
c Instructor’s Manual to accompany Introduction to Matlab 6 for Engineers by William J. Palm III University of Rhode Island

c Instructor’s Manual Copyright 2000 by McGraw-Hill Companies, Inc.

0-1

Solutions to Problems in Chapter One Test Your Understanding Problems T1.1-1 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.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 poly(ans) ans = 1.0000 6.0000 -11.0000 290.0000 which are the given coefficients. Thus the roots are −10 and 2 ± 5i. T1.3-3 a) b) z = c) z = d) z =

z 1 1 0

= 0 0 0

0 0 1 0

0 0 1 0

1 1 1 0 1 1

T1.3-4 The session is: x = [-4, -1, 0, 2, 10];y = [-5, -2, 2, 5, 9]; x(x>y) ans = -4 -1 10 find(x>y) ans = 1 2 5

1-1

T1.3-5 The session is: t = [0:0.01:5]; s = 2*sin(3*t+2) + sqrt(5*t+1); plot(t,s),xlabel(0Time (sec)0 ),ylabel(0Speed (ft/sec)0)

7

6

Speed s (ft/sec)

5

4

3

2

1

0

0

0.5

1

1.5

2

2.5 Time t (sec)

3

3.5

4

4.5

5

Figure : for Problem T1.3-5 T1.3-6 The session is: x = [0:0.01:1.55]; s = 4*sqrt(6*x+1); z = polyval([4,6,-5,3],x); plot(x,y,x,z,0--0 ),xlabel(0Distance (meters)0),ylabel(0Force (newtons)0

T1.3-7 The session is: A = [6, -4, 8; -5, -3, 7; 14, 9, -5]; b = [112; 75; -67]; x = A\b 1-2

25

Force (newtons)

20

15

10 y

5 z

0

0

0.5

1 Distance x (meters)

Figure : for Problem T1.3-6 x = 2.0000 -5.0000 10.0000 A*x ans = 112 75 -67 Thus the solution is x = 2, y = −5, and z = 10. T1.4-1 The session is: a = 112; b = 75; c = -67; A = [6, -4, 8; -5, -3, 7; 14, 9, -5]; bvector = [a; b; c]; x = A\bvector x = 2.0000 -5.0000 10.0000 1-3

1.5

A*x ans = 112 75 -67 Thus the solution is x = 2, y = −5, and z = 10. T1.4-2 The script file is: x = -5; if x < 0 y = sqrt(x^2+1) elseif x < 10 y = 3*x+1 else y = 9*sin(5*x-50)+31 end For x = −5, y = 5.0990. Changing the first line to x = 5 gives y = 16. Changing the first line to x = 15 gives y = 29.8088. T1.4-3 The script file is sum = 0; for k = 1:20 sum = sum + 3*k^2; end sum The answer is sum = 8610. T1.4-4 The script file is sum = 0;k = 0; while sum y) ans = -15 9 find(x>y) ans = 1 3 The first and third elements of x are greater than the first and third elements of y. 20. The session is: t = [1:0.005:3]; T = 6*log(t) - 7*exp(-0.2*t); plot(t,T),title(0Temperature Versus Time0 ),... xlabel(0Time t (minutes)0),ylabel(0Temperature T (◦ C)0 ) The plot is shown in the figure. 1-10

Temperature Versus Time 3

2

1

o

Temperature T ( C)

0

−1

−2

−3

−4

−5

−6

1

1.2

1.4

1.6

1.8

2 2.2 Time t (minutes)

2.4

2.6

Figure : for Problem 20 21. 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(0Speed (miles/hour)0),... xlabel(0Distance x (miles)0) The plot is shown in the figure.

1-11

2.8

3

5

4 u

Speed (miles/hour)

3

v

2

1

0

−1

−2

−3

0

0.2

0.4

0.6

0.8 1 1.2 Distance x (miles)

1.4

Figure : for Problem 21

1-12

1.6

1.8

2

22. The session is: x = [-3:0.01:3]; p1 = [3,-6,8,4,90]; p2 = [3,5,-8,70]; y = polyval(p1,x); z = polyval(p2,x); plot(x,y,x,z,0--0 ),ylabel(0Current (milliamps)0),... xlabel(0Voltage x (volts)0 ) The plot is shown in the figure. 600

500

Current (milliamps)

400

300

y

200

100 z

0 −3

−2

−1

0 Voltage x (volts)

1

Figure : for Problem 22

1-13

2

3

23. The session is: p = [3,-5,-28,-5,200]; x = [-1:0.005:1]; y = polyval(p,x); plot(x,y),ylabel(0y0 ),xlabel(0x0 ),ginput(1) The peak as measured with the mouse cursor is y = 200.3812 at x = −0.0831 205

200

y

195

190

185

180

175 −1

−0.8

−0.6

−0.4

−0.2

0 x

0.2

0.4

0.6

0.8

1

Figure : for Problem 23 24. The session is: A = [7,14,-6;12,-5,9;-5,7,15]; b = [95;-50;145]; x = A\b The answers are −3, 10, and 4, which correspond to x = −3, y = 10, and z = 4. Typing A*x gives the result 95, -50, 145, which are the right-hand sides of the equations. Thus the values of x, y, and z are correct. 25. The script file is: 1-14

x = -5; if x < -1 y = exp(x + 1) elseif x < 5 y = 2 + cos(pi*x) else y = 10*(x - 5) + 1 end The answer for x = −5 is y = 0.0183. Change the first line to x = 3 to obtain y = 1. Then change the first line to x = 15 to obtain y = 101. 26. The script file is: sum = 0; for k = 1:10 sum = sum + 5*k^3; end sum The answer is sum = 15125. 27. The script file is: sum = 0;k = 0; while sum