Page 86 - MATLAB an introduction with applications
P. 86
MATLAB Basics ——— 71
ans =
98.5461
2.2964
–1.3095
–6.5329
The eigenvectors are:
>> [Q, d] = eig (a)
Q =
– 0.3263 – 0.2845 0.3908 0.3413
– 0.3619 0.7387 – 0.7816 – 0.9215
– 0.8168 – 0.6026 0.4769 0.0962
– 0.3089 0.1016 – 0.0950 0.1586
d =
98.5461 0 0 0
0 2.2964 0 0
0 0 – 1.3095 0
0 0 0 – 6.5329
Example E1.21: Solve the following set of equations using MATLAB:
(a) x + 2x + 3x + 5x = 21
1
3
4
2
–2x + 5x + 7x – 9x = 18
1
2
3
4
5x + 7x + 2x – 5x = 25
3
2
1
4
–x + 3x – 7x + 7x = 30
4
1
2
3
(b) x + 2x + 3x + 4x = 8
4
3
2
1
2x – 2x – x – x = –3
2
4
3
1
x – 3x + 4x – 4x = 8
3
4
1
2
2x + 2x – 3x + 4x = –2
1
4
3
2
Solution:
(a) >> A = [1 2 3 5;–2 5 7 –9; 5 7 2 –5; –1 –3 –7 7];
>> B = [21; 18; 25; 30];
>> S = A\B
S =
– 8.9896
14.1285
– 5.4438
3.6128
% Therefore x = – 8.9896, x =14.1285, x = – 5.4438, x =3.6128.
1 2 3 4
(b) >> A = [1 2 3 4; 2 –2 –1 1; 1 –3 4 –4; 2 2 –3 4];
>> B = [8;–3; 8;–2];
>> S =A\B
F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09