Introduction to Matlab 6 for Engineers

# Introduction to Matlab 6 for Engineers - Solutions to...

This preview shows pages 1–9. Sign up to view the full content.

Solutions to Problems in Chapter Two Test Your Understanding Problems T2.1-1 The session is ± B = [2,4,10,13;16,3,7,18;8,4,9,25;3,12,15,17]; ± A=[B;B 0 ] ± A(5,3) A= 2 4 10 13 163718 84925 3121517 21683 43412 107915 13 18 25 17 ans = 8 T2.1-2 a) The session is ± B = [2,4,10,13;16,3,7,18;8,4,9,25;3,12,15,17]; ± [x,k] = max(B); ± [maxB,column]=max(x) maxB = 25 column = 4 ± row=k(column) row = 3 b) Continue the above session as follows: ± C = sort(B) C= 23713 34917 8 4 10 18 16 12 15 25 2-1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
T2.3-1 a) The session is ± A = [21,27;-18,8];B = [-7,-3;9,4]; ± A.*B ans = -147 -81 -162 32 ± A./B ans = -3 -9 -2 2 ± B.^3 ans = -343 -27 729 64 T2.4-1 The session is ± u = [6,-8,3]; w = [5,3,-4] ± u*w 0 ans = -6 T2.4-2 The session is ± A = [7,4;-3,2;5,9];B = [1,8;7,6] ± A*B ans = 35 80 11 -12 68 94 T2.4-3 The session is ± A = [6,-2;10,3];B = [9,8;-12,14] ± A*B ans = 78 20 54 122 ± B*A ans = 134 6 68 66 2-2
T2.5-1 The session is ± p1 = [20,-7,5,10];p2 = [4,12,-3] ± conv(p1,p2) ans = 80 212 -124 121 105 -30 T2.5-2 The session is ± p1 = [12,5,-2,3];p2 =[3,-7,4 ] ± [q,r] = deconv(p1,p2) q= 4.0000 11.0000 r= 0 0.0000 59.0000 -41.0000 T2.5-3 The session is ± p1 = [6,4,0,-5];p2 = [12,-7,3,9] ± ratio = polyval(p1,2)/polyval(p2,2) ratio = 0.7108 Using the deconv command, the session is ± p1 = [6,4,0,-5]; p2 = [12,-7,3,9] ± [q,r] = deconv(p1,p2); ± ratio = polyval(q,2)+polyval(r,2)/polyval(p2,2) ratio = 0.7108 End-of-Chapter Problems 1. a) Either x = [5:23/99:28] or x = linspace(5,28,100) will work. b) Either x = [2.:.2:14] or x=linspace(2,14,61) will work. c) Either x = [-2:1/7:5] or Either x = linspace(-2,5,50) will work. 2. a) Type logspace(1,3); b) Type logspace(1,3,20); 3. The session is ± x = linspace(0,10,6); ± A = [3*x;5*x-20] 2-3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
A= 0 6 12 18 24 30 -20-100102030 4. Use the transpose operator. The session is ± x = linspace(0,10,6); ± A = [3*x;5*x-20] 0 0 -20 6 -10 12 0 18 10 24 20 30 30 5. The session is ± A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1]; ± v = A(:,2); ± w = A(2,:); 6. The session is ± A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1]; ± B = A(:,2:4); ± C = A(2:4,:); ± D = A(1:2,2:4); 7. The length is 3 for all three vectors. The following session computes the absolute values. ± x = [2,4,7]; ± length(x) ans = 3 ± abs(x) ans = 247 ± y=[2,-4,7]; ± abs(y) ans = 2-4
247 ± z=[5+3i,-3+4i,2-7i]; ± abs(z) ans = 5.8310 5.0000 7.2801 8. The session is ± A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1]; ± min(A) ans = -55-41 ± max(A) ans = 15 13 10 12 ± min(A 0 ) ans = -4 -5 6 1 ± max(A 0 ) ans = 12 10 13 15 9. The session is ± A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1]; ± B = sort(A) B= 3742 69811 15 13 10 12 ± C = [sort(A 0 )] 0 C= -43712 -52910 6 8 11 13 14515 ± D = sum(A) D= 19 34 18 26 ± E = sum(A 0 ) E= 2-5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
18 16 38 25 10. a) The session is ± A = [1,4,2;2,4,100;7,9,7;3,pi,42]; ± B = log(A) ± B(2,:) The answers are 0.6931, 1.3863, and 4.6052. b) Type sum(B(2,:)) . The answer is 6.6846. c) Type B(:,2).*A(:,1) . The answers are 1.3863, 2.7726, 15.3806, 3.4342. d) Type max(B(:,2).*A(:,1)) . The answer is 15.3806. e) Type sum(A(1,:)./B(1:3,3)) 0 . The answer is 3.3391. 11. The script ﬁle is A = [3,-2,1;6,8,-5;7,9,10]; B = [6,9,-4;7,5,3;-8,2,1]; C = [-7,-5,2;10,6,1;3,-9,8]; D(:,:,1) = A; D(:,:,2) = B; D(:,:,3) = C; max(max(D)) max(max(max(D))) While this ﬁle is run, it produces the results: ans(:,:,1) = 10 ans(:,:,2) = 9 ans(:,:,3) = 10 ans = 10 Thus the largest element in the ﬁrst, second, and third layer is 10, 9, and 10 respectively. The largest element in the entire array is 10. 12. The session is 2-6
± A = [-7,16;4,9]; B = [6,-5;12,-2]; C = [-3,-9;6,8]; ± A+B+C ans = -4 2 22 15 ± A-B+C ans = -16 12 -2 19 ± (A+B)+C ans = -4 2 22 15 ± A+(B+C) ans = -4 2 22 15 ± A+B+C ans = -4 2 22 15 ± B+C+A ans = -4 2 22 15 ± A+C+B ans = -4 2 22 15 13. The session is ± A = [64,32;24,-16]; B = [16,-4;6,-2]; ± A.*B ans = 1024 -128 144 32 ± A./B ans = 4-8 48 ± B.^3 2-7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ans = 4096 -64 216 -8 14. The session is ± F = [400,550,700,500,600]; D = [2,.5,.75,1.5,3]; ± W = F.*D W= 800 275 525 750 1800 ± Total_Work = sum(W) Total_Work = 4150 The work done on each segment is 800, 275, 750, and 1800 joules, respectively. (1 joule = 1 N m.) The total work done is 4150 joules.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/21/2009 for the course ENGR 290 taught by Professor Priritera during the Spring '05 term at S. Alabama.

### Page1 / 22

Introduction to Matlab 6 for Engineers - Solutions to...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online