CHAPTER 8
CHAPTER 8
8.1 8.1 >
>> > AAug ug = = [[ A A eyeeye(( sisi ze(ze( AA)) )) ]] Here’s an example session of how
Here’s an example session of how it can be employed.it can be employed. > >> > A = A = rr and(and( 3)3) A A == 0. 0. 959501 01 0.0. 484860 60 0.0. 45456565 0. 0. 232311 11 0.0. 898913 13 0.0. 01018585 0. 0. 606068 68 0.0. 767621 21 0.0. 82821414 >
>> > AAug ug = = [[ A A eyeeye(( sisi ze(ze( AA)) )) ]] Aug = Aug = 0. 0. 959501 01 0.0. 484860 60 0.0. 454565 65 1.1. 000000 00 0 0 00 0. 0. 232311 11 0.0. 898913 13 0.0. 010185 85 0 0 1.1. 000000 00 00 0. 0. 606068 68 0.0. 767621 21 0.0. 828214 14 0 0 0 0 1.1. 00000000 8.2 (a)
8.2 (a) [ [ A A]: 3]: 3
2 2 [[ B B]: 3]: 3
3 3 {{C C }: 3}: 3
1 1 [[ D D]: 2]: 2
4 4 [[ E E ]: 3]: 3
3 3 [[F F ]: 2]: 2
3 3
GG
: 1: 1
3 3(b)
(b)square: [ Bsquare: [ B], [], [ E E ]; column: {]; column: {C C }, row:}, row:
GG
(c)(c)aa1212 = 5, b = 5,b2323 = 6, = 6, d d 3232 = undefined, = undefined, ee2222 = 1, = 1, f f 1212 = 0, = 0, gg1212 = 6 = 6
(d) (d)
(1)
(1) (2) (2) [[ A A] + [] + [F F ] = undefined] = undefined 5 5 88 1133 [[ ]] [[ ]] 88 33 99 6 6 00 1100 E E BB
(3) (4) (3) (4) 3 3 22 11 [[ ]] [[ ]] 66 11 33 2 2 00 22 B B E E
2 288 2211 4499 7 7[ ][ ] 77 1144 4422 1 144 00 2288 B B
((55) ) [[ ] C C ] T T
2 62 6 11
((66)) 2 211 1133 6611 [[ ]][[ ]] 3355 2233 6677 2 288 1122 5522 E E BB
(7) (8) (7) (8) 5 533 2233 7755 [ ] [ ][[ ]] 3399 77 4488 1 188 1100 3366 B B E E
5 5 22 4 4 11 [[ ]] 3 3 77 7 7 55 T T D D
(9) [ (9) [GG][][C C ] ] = = 56 56 (10)(10) 4 4 33 77 [[ ]] 11 22 66 2 2 00 44 I I BB
(11) (12) (11) (12) C C C C 6 666 1122 5511 [[ ]] 1122 2266 3333 5 511 3333 8811 T T E E E E
T T [[ ]]
44118.3 The terms can be collected to give 1 2 3 0 6 5 50 0 2 7 30 4 3 7 50 x x x
Here is the MATLAB session:
>> A = [ 0 - 6 5; 0 2 7; - 4 3 - 7] ; >> b = [ 50; - 30; 50] ; >> x = A\ b x = - 17. 0192 - 9. 6154 - 1. 5385 >> AT = A' 0 0 - 4 - 6 2 3 5 7 - 7 >> AI = i nv( A) AI = - 0. 1683 - 0. 1298 - 0. 2500 - 0. 1346 0. 0962 0 0. 0385 0. 1154 0
8.4 (a) Here are all the possible multiplications: >> A=[ 6 - 1; 12 7; - 5 3] ; >> B=[ 4 0; 0. 6 8] ; >> C=[ 1 - 2; - 6 1] ; >> A* B ans = 23. 4000 - 8. 0000 52. 2000 56. 0000 - 18. 2000 24. 0000 >> A* C ans = 12 - 13 - 30 - 17 - 23 13 >> B* C ans = 4. 0000 - 8. 0000 - 47. 4000 6. 8000 >> C* B ans = 2. 8000 - 16. 0000 - 23. 4000 8. 0000
(b) [ B][ A] and [C ][ A] are impossible because the inner dimensions do not match: (2
2) * (3
2)8.5 >> A=[ 3+2*i 4; - i 1] >> b=[ 2+i ; 3] >> z=A\ b z = - 0. 5333 + 1. 4000i 1. 6000 - 0. 5333i 8.6 f unct i on X=mmul t ( Y, Z)
% mmul t : mat r i x mul t i pl i cat i on % X=mmul t ( Y, Z)
% mul t i pl i es t wo mat r i ces % i nput :
% Y = f i rst mat r i x % Z = second mat r i x % out put :
% X = pr oduct
i f nar gi n<2, er r or ( ' at l east 2 i nput ar gument s r equi r ed' ) , end [ m, n] =si ze( Y) ; [ n2, p] =si ze( Z) ;
i f n~=n2, err or( ' I nner matr i x di mensi ons must agr ee. ' ) , end f or i =1: m f or j =1: p s=0. ; f or k=1: n s =s +Y( i , k) * Z( k, j ) ; end X( i , j ) =s ; end end
Test of function for cases from Prob. 8.4: >> A=[ 6 - 1; 12 7; - 5 3] ; >> B=[ 4 0; 0. 6 8] ; >> C=[ 1 - 2; - 6 1] ; >> mmul t ( A, B) ans = 23. 4000 - 8. 0000 52. 2000 56. 0000 - 18. 2000 24. 0000 >> mmul t ( A, C) ans = 12 - 13 - 30 - 17 - 23 13 >> mmul t ( B, C) ans = 4. 0000 - 8. 0000 - 47. 4000 6. 8000 >> mmul t ( C, B) ans = 2. 8000 - 16. 0000 - 23. 4000 8. 0000 >> mmul t ( B, A)
?? ? Er r or usi ng ==> mmul t
I nner mat r i x di mensi ons must agr ee. >> mmul t ( C, A)
?? ? Er r or usi ng ==> mmul t
I nner mat r i x di mensi ons must agr ee. 8.7
f unct i on AT=mat r an( A)
% mat r an: mat r i x t r anspose % AT=mt r an( A)
% generat es t he t r anspose of a mat r i x % i nput : % A = or i gi nal mat r i x % out put : % AT = t r anspose [ m, n] =si ze( A) ; f or i = 1: m f or j = 1: n AT( j , i ) = A( i , j ) ; end end
Test of function for cases from Prob. 8.4: >> mat r an( A) ans = 6 12 - 5 - 1 7 3 >> mat r an( B) 4. 0000 0. 6000 0 8. 0000 >> mat r an( C) ans = 1 - 6 - 2 1 8.8 f unct i on B = permut ( A, r 1, r 2)
% permut : Swi t ch r ows of mat r i x A wi t h a permut at i on mat r i x % B = permut ( A, r 1, r 2)
% i nput :
% A = or i gi nal mat r i x
% r 1, r 2 = r ows t o be swi t ched % out put :
% B = mat r i x wi t h r ows s wi t ched [ m, n] = si ze( A) ;
i f m ~= n, er r or ( ' mat r i x not squar e' ) , end i f r 1 == r 2 | r 1>m | r 2>m
err or( ' r ow numbers ar e equal or exceed mat r i x di mensi ons' ) end P = zeros( n) ; P( r 1, r2)=1; P( r 2, r 1) =1; f or i = 1: m i f i ~=r 1 & i ~=r 2 P( i , i ) =1; end
end B=P* A; Test script: cl c A=[ 1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16] B = per mut ( A, 3, 1) B = per mut ( A, 3, 5) A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 B = 9 10 11 12 5 6 7 8 1 2 3 4 13 14 15 16
?? ? Er r or usi ng ==> per mut
r ow number s ar e equal or exceed mat r i x di mensi ons Err or i n ==> per mut Scr i pt at 4
B = per mut ( A, 3, 5)
8.9 The mass balances can be written as
15 12 1 31 3 01 01 12 1 23 24 25 2 ( ) ( ) Q Q c Q c Q c Q c Q Q Q c
23 2 31 34 3 03 03 24 2 34 3 44 4 54 5 0 ( ) Q c Q Q c Q c Q c Q c Q c Q c
15 1 25 2 54 55 5 0 ( ) 0 Q c Q c Q Q c
The parameters can be substituted and the result written in matrix form as
1 2 3 4 5 9 0 3 0 0 120 4 4 0 0 0 0 0 2 9 0 0 350 0 1 6 9 2 0 5 1 0 0 6 0 c c c c c
The following MATLAB script can then be used to solve for the concentrations cl c Q = [ 9 0 - 3 0 0; - 4 4 0 0 0; 0 - 2 9 0 0; 0 - 1 - 6 9 - 2; - 5 - 1 0 0 6] ; Qc = [ 120; 0; 350; 0; 0] ; c = Q\ Qc c =
28. 4000 28. 4000 45. 2000 39. 6000 28. 4000
8.10The problem can be written in matrix form as
1 2 3 2 2 3 0.866025 0 0.5 0 0 0 0 0.5 0 0.866025 0 0 0 2000 0.866025 1 0 1 0 0 0 0.5 0 0 0 1 0 0 0 1 0.5 0 0 0 0 0 0 0.866025 0 0 1 0 F F F H V V
MATLAB can then be used to solve for the forces and reactions, cl c; f or mat shor t g A = [ 0. 866025 0 - 0. 5 0 0 0; 0. 5 0 0. 866025 0 0 0; - 0. 866025 - 1 0 - 1 0 0; - 0. 5 0 0 0 - 1 0; 0 1 0. 5 0 0 0; 0 0 - 0. 866025 0 0 - 1] ; b = [ 0 - 2000 0 0 0 0] ' ; F = A\ b F = - 1000 866. 03 - 1732. 1 0 500 1500 Therefore, F 1 = –1000 F 2 = 866.025 F 3 = –1732.1 H 2 = 0 V 2 = 500 V 3 = 1500 8.11 cl c; f or mat shor t g k1=10; k2=40; k3=40; k4=10; m1=1; m2=1; m3=1; km=[ ( 1/ m1) *( k2+k1) , - ( k2/ m1) , 0 - ( k2/ m2) , ( 1/ m2) *( k2+k3) , - ( k3/ m2) 0, - ( k3/ m3) , ( 1/ m3) *( k3+k4) ] x=[ 0. 05; 0. 04; 0. 03] ; kmx=- km*x km = 50 - 40 0 - 40 80 - 40 0 - 40 50 kmx = - 0. 9 - 2. 2204e- 016 0. 1
Therefore,
x
1 = –0.9,x
2= 0 , andx
3= 0.1 m/s2.8.12 Vertical force balances can be written to give the following system of equations,
1 2 2 1 1 1 2 3 3 2 2 2 1 3 4 4 3 3 3 2 4 5 5 4 4 4 3 5 5 5 4 ( ) 0 ( ) ( ) ( ) ( ) ( ) ( ) ( ) 0 m g k x x k x m g k x x k x x m g k x x k x x m g k x x k x x m g k x x
0 0 0
Collecting terms, 1 2 2 1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5 4 4 5 5 5 5 k k k x mg k k k k x m g k k k k x m g k k k k x m g k k x m g
After substituting the parameters, the equations can be expressed as ( g = 9.81),
1 2 3 4 5 120 40 637.65 40 110 70 735.75 70 170 100 588.60 100 120 20 735.75 20 20 882.90 x x x x x
The solution can then be obtained with the following MATLAB script: cl c; f or mat shor t g g=9. 81; m1=65; m2=75; m3=60; m4=75; m5=90; k1=80; k2=40; k3=70; k4=100; k5=20; A=[ k1+k2 - k2 0 0 0 - k2 k2+k3 - k3 0 0 0 - k3 k3+k4 - k4 0 0 0 - k4 k4+k5 - k5 0 0 0 - k5 k5] b=[ m1*g m2*g m3*g m4*g m5*g] ' x=A\ b A = 120 - 40 0 0 0 - 40 110 - 70 0 0 0 - 70 170 - 100 0 0 0 - 100 120 - 20 0 0 0 - 20 20 b = 637. 65 735. 75 588. 6
735. 75 882. 9 x = 44. 758 118. 33 149. 87 166. 05 210. 2
8.13 The position of the three masses can be modeled by the following steady-state force balances
2 1 1 1 3 2 2 2 1 3 3 2 0 ( ) 0 ( ) ( 0 ( ) k x x m g kx k x x m g k x x m g k x x
)
Terms can be combined to yield
1 2 1 1 2 3 2 2 3 3 2 2 kx kx m g kx kx kx m g kx kx m g
Substituting the parameter values
1 2 3 30 15 0 19.62 15 30 15 24.525 0 15 15 29.43 x x x
A MATLAB script can be used to obtain the solution for the displacements cl c; f or mat shor t g g=9. 81; k=15; K=[ 2*k - k 0; - k 2*k - k; 0 - k k] m=[ 2; 2. 5; 3] ; mg=m*g x=K\ mg K = 30 - 15 0 - 15 30 - 15 0 - 15 15 mg = 19. 62 24. 525 29. 43 x = 4. 905 8. 502 10. 464
12 52 32 65 52 32 54 43 54 12 52 65 43 1 6 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 i i i i R R R R i R R R i V V
0
or substituting the resistances
12 52 32 65 54 43 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 10 10 0 15 5 0 5 10 0 20 0 0 200 i i i i i i
This system can be solved with MATLAB, cl c; f or mat shor t g R12=5; R52=10; R32=10; R65=20; R54=15; R43=5; V1=200; V6=0; A=[ 1 1 1 0 0 0; 0 - 1 0 1 - 1 0; 0 0 - 1 0 0 1; 0 0 0 0 1 - 1; 0 R52 - R32 0 - R54 - R43; R12 - R52 0 - R65 0 0] B=[ 0 0 0 0 0 V1- V6] ' I =A\ B A = 1 1 1 0 0 0 0 - 1 0 1 - 1 0 0 0 - 1 0 0 1 0 0 0 0 1 - 1 0 10 - 10 0 - 15 - 5 5 - 10 0 - 20 0 0 B = 0 0 0 0 0 200 I = 6. 1538 - 4. 6154 - 1. 5385 - 6. 1538 - 1. 5385 - 1. 5385 i21 = 6.1538 i52 =
4.6154 i32 =
1.5385 i65 =
i54 =
1.5385 i43 =
1.5385Here are the resulting currents superimposed on the circuit: 6.1538 1.5385 6.1538 1.5385 1.5385 1 . 5 3 8 5 0 200 –6.1538 – 4 . 6 1 5 4
8.15 The current equations can be written as
0
52 23 21
i
i
i
0
43 35 23
i
i
i
0
54 43
i
i
0
54 65 52 35
i
i
i
i
Voltage equations: 2 21 20 35 V i
5 4 54 15 V V i
2 3 23 30 V V i
3 5 35 7 V V i
4 3 43 8 V V i
5 2 52 10 V V i
5 65 140 5 V i
21 23 52 35 43 54 65 2 3 4 5 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 35 0 0 0 0 0 0 1 0 0 0 0 30 0 0 0 0 0 1 1 0 0 0 0 0 0 8 0 0 0 1 1 0 0 0 0 0 0 15 0 0 0 1 1 0 0 0 7 0 0 0 0 1 0 1 0 0 10 0 0 0 0 1 0 0 1 0 0 0 0 0 0 5 0 0 0 1 i i i i i i i V V V V
0 0 0 0 20 0 0 0 0 0 140
A MATLAB script can be developed to generate the solution, cl c; f or mat shor t g
R12=35; R52=10; R32=30; R34=8; R45=15; R35=7; R25=10; R65=5; V1=20; V6=140;
A=[ - 1 - 1 1 0 0 0 0 0 0 0 0; 0 1 0 - 1 1 0 0 0 0 0 0;
0 0 0 0 - 1 1 0 0 0 0 0; 0 0 - 1 1 0 - 1 1 0 0 0 0; R12 0 0 0 0 0 0 - 1 0 0 0; 0 R32 0 0 0 0 0 - 1 1 0 0; 0 0 0 0 R34 0 0 0 1 - 1 0; 0 0 0 0 0 R45 0 0 0 1 - 1; 0 0 0 R35 0 0 0 0 - 1 0 1; 0 0 R25 0 0 0 0 1 0 0 - 1; 0 0 0 0 0 0 R65 0 0 0 1] B=[ 0 0 0 0 - V1 0 0 0 0 0 V6] ' I =A\ B I = 2. 5107 - 0. 55342 1. 9573 - 0. 42429 0. 12913 0. 12913 2. 5107 107. 87 124. 48 125. 51 127. 45 Thus, the solution is
i21 = 2.5107 i23 =
0.55342 i52 = 1.9573 i35 =
0.42429 i43 = 0.12913i54 = 0.12913 i65 = 2.5107 V 2 = 107.87 V 3 = 124.48 V 4 = 125.51