# M7solns2 - Solutions to Problems in Chapter Two Test Your...

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 ± ] ± A(5,3) A= 241013 16 3 7 18 84925 3 12 15 17 21683 43412 10 7 9 15 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 841018 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 ± 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 2-2
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 T2.5-1 The session is ± roots([1,13,52,6]) ans = -6.4406 + 2.9980i -6.4406 - 2.9980i -0.1189 ± poly(ans) ans = 1.0000 13.0000 52.0000 6.0000 T2.5-2 The session is ± p1 = [20,-7,5,10];p2 = [4,12,-3] ± conv(p1,p2) ans = 80 212 -124 121 105 -30 2-3

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

View Full Document
T2.5-3 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-4 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 T2.5-5 The session is ± x = [-7:0.01:1]; ± plot(x,polyval([1,13,52,6],x)),xlabel( ± x ± ),ylabel( ± y ± ) T2.6-1 Using cell indexing to create a 1 × 4 cell array, the script fle is: A { 1 } = [1:4]; A { 2 } = [0,9,2]; A { 3 } = [2:5]; A { 4 } = [6:8]; [x,y] = deal(A { 1:2 } ); B = [x,y] C=[A { 2 } ;A { 4 } ] [u,v] = deal(A { 2:3 } ); D = min([u,v]) 2-4
T2.7-1 The script fle is student(1).name = ± John Smith ± ; student(1).SSN = ± 392-77-1786 ± ; student(1).email = ± [email protected] ± ; student(1).tests = [67,75,84]; student(2).name = ± Mary Jones ± ; student(2).SSN = ± 431-56-9832 ± ; student(2).email = ± [email protected] ± ; student(2).tests = [84,78,93]; student(3).name = ± Alfred E. Newman ± ; student(3).SSN = ± 555-12-3456 ± ; student(3).email = ± [email protected] ± ; student(3).tests = [55,45,58]; T2.7-2 The session is ± student(3).tests(2) = 53; T2.7-3 The session is ± new_student = rmfield(student, ± SSN ± ) 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] A= 0612182430 -20 -10 0 10 20 30 2-5

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

View Full Document
4. Use the transpose operator. The session is ± x = linspace(0,10,6); ± A = [3*x;5*x-20] ± A= 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 = ± z=[5+3i,-3+4i,2-7i]; ± abs(z) ans = 5.8310 5.0000 7.2801 2-6
8. The session is ± A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1]; ± min(A) ans = -5 5 -4 1 ± max(A) ans = 15 13 10 12 ± min(A ± ) ans = -4 -5 6 1 ± max(A ± ) 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= -5 5 -4 1 3742 69811 15 13 10 12 ± C = [sort(A ± )] ± C= -4 3 7 12 -5 2 9 10 681113 14515 ± D = sum(A) D= 19 34 18 26 ± E = sum(A ± ) E= 18 16 38 25 2-7

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

View Full Document
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.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/02/2008 for the course ENGINEERIN 127 taught by Professor Finch during the Spring '08 term at Rutgers.

### Page1 / 32

M7solns2 - Solutions to Problems in Chapter Two Test Your...

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

View Full Document
Ask a homework question - tutors are online