Page 230 - MATLAB an introduction with applications
P. 230
Numerical Methods ——— 215
MATLAB Solution [Using built-in function]:
>> A = [2 1 –3; 4 –2 3; –2 2 –1];
>> B = [11; 8; –6];
>> x = inv(A)*B
>> x = A\B
x =
3
–1
–2
>> x = inv(A)*B
x =
3.0000
–1.0000
–2.0000
Example E4.2: Using Gaussian elimination method, solve the system of linear equations:
2x + x + x – x =10
1
4
3
2
x + 5x – 5x + 6x =25
1
2
4
3
–7x + 3x – 7x – 5x =5
2
1
4
3
x – 5x + 2x + 7x =11
1
2
3
4
Solution:
EDU >> Run_pr_E4.2
A =
2 1 1 –1
1 5 –5 6
–7 3 –7 –5
1–5 2 7
B =
10
25
5
11
x =
25.3587
–19.6143
–28.9058
–7.8027
det =
–223.0000
x =
25.3587
–19.6143
–28.9058
–7.8027