Graphics Programs Reference
In-Depth Information
check =
1.0000
-0.0000
-0.0000
0
1.0000
0.0000
0
-0.0000
1.0000
EXAMPLE 2.14
Invert the matrix
2
1
0000
12
1
000
0
12
1
00
A
=
00
12
1
0
000
12
1
0000
15
Solution Since the matrix istridiagonal, we solve AX
I using the functions LUdec3
and LUsol3 (LU decomposition for tridiagonal matrices):
=
% Example 2.14 (Matrix inversion)
n=6;
d = ones(n,1)*2;
e = -ones(n-1,1);
c=e;
d(n) = 5;
[c,d,e] = LUdec3(c,d,e);
fori=1:n
b = zeros(n,1);
b(i) = 1;
Ainv(:,i) = LUsol3(c,d,e,b);
end
Ainv
The result is
>> Ainv =
0.8400
0.6800
0.5200
0.3600
0.2000
0.0400
0.6800
1.3600
1.0400
0.7200
0.4000
0.0800
0.5200
1.0400
1.5600
1.0800
0.6000
0.1200
0.3600
0.7200
1.0800
1.4400
0.8000
0.1600
0.2000
0.4000
0.6000
0.8000
1.0000
0.2000
0.0400
0.0800
0.1200
0.1600
0.2000
0.2400
Note that although A istridiagonal, A 1 isfullypopulated.
Search WWH ::




Custom Search