Page 135 - Numerical Analysis Using MATLAB and Excel
P. 135
Minors and Cofactors
if n==2
y=det2x2(A);
return
end
%
if n==3
y=det3x3(A);
return
end
% For 4x4 or higher order matrices we use the following:
% (We can define n and matrix A in Command Window
for i=1:n
y=y+(−1)^(i+1)*A(1,i)*detnxn(A(2:n, [1:(i−1) (i+1):n]));
end
%
% To run this program, define the nxn matrix in
% MATLAB's Command Window as A=[....] and then
% type detnxn(A) at the command prompt.
Some useful properties of determinants are given below.
Property 1:
If all elements of one row or one column are zero, the determinant is zero. An example of this is the
determinant of the cofactor c[] above.
Property 2:
If all the elements of one row or column are m times the corresponding elements of another row or col-
umn, the determinant is zero. For example, if
2 4 1
A = 3 6 1 (4.28)
1 2 1
then,
2 4 1 2 4
detA = 3 6 1 3 6 = 12 ++ 6 – 6 4 – 12 = 0 (4.29)
–
4
1 2 1 1 2
Here, detA is zero because the second column in is 2 times the first column.
A
Check with MATLAB:
A=[2 4 1; 3 6 1; 1 2 1]; det(A)
ans =
0
Numerical Analysis Using MATLAB® and Excel®, Third Edition 4−17
Copyright © Orchard Publications