MATLAB Matrix Question This question below is composed of 2
MATLAB Matrix Question!!!
This question below is composed of 2 m-files.
1. lup_decomp.m
2. ch2_1.m
Please read the attached file and write all of m-files exactly.
Thanks :)
Solution
A =
-5 -3 -5 1 -2 1
5 1 -1 -4 3 -1
-4 -3 3 4 -4 3
0 -2 -3 2 -3 2
2 1 -2 -5 0 -1
1 3 1 2 4 0
[L U P]=lu(A)
L =
1.0000 0 0 0 0 0
-0.2000 1.0000 0 0 0 0
0.8000 -0.2500 1.0000 0 0 0
0 -0.8333 -0.4286 1.0000 0 0
-1.0000 -0.8333 -0.8571 0.3764 1.0000 0
-0.4000 -0.0833 -0.5714 -0.4179 -0.5500 1.0000
U =
-5.0000 -3.0000 -5.0000 1.0000 -2.0000 1.0000
0 2.4000 0 2.2000 3.6000 0.2000
0 0 7.0000 3.7500 -1.5000 2.2500
0 0 0 5.4405 -0.6429 3.1310
0 0 0 0 2.9562 0.9168
0 0 0 0 0 2.5152
P =
1 0 0 0 0 0
0 0 0 0 0 1
0 0 1 0 0 0
0 0 0 1 0 0
0 1 0 0 0 0
0 0 0 0 1 0
b=[1;1;1;1;1;1]
b =
1
1
1
1
1
1
d=inv(L)*P*b
d =
1.0000
1.2000
0.5000
2.2143
2.5952
4.1384
x=inv(U)*d
x =
-0.1645
0.2666
-0.1127
-0.4965
0.3676
1.6454

