Page 235 - MATLAB an introduction with applications
P. 235
220 ——— MATLAB: An Introduction with Applications
L =
0.3333 –0.0000 1.0000
1.0000 0 0
0.6667 1.0000 0
U =
3.0000 3.0000 4.0000
0 –1.0000 –1.6667
0 0 –0.3333
>> L*U
ans =
1.0000 1.0000 1.0000
3.0000 3.0000 4.0000
2.0000 1.0000 1.0000
>> d = L\B
d =
23.0000
– 5.3333
– 0.6667
>> x = U\d
x =
3.0000
2.0000
2.0000
Check with MATLAB [Using built-in function]:
>> A = [1 1 1;3 3 4;2 1 1];
>> B = [7;23;10];
>> x = A\B
x =
3.0000
2.0000
2.0000
>> x = inv(A)*B
x =
3.0000
2.0000
2.0000