Page 134 - Numerical Analysis Using MATLAB and Excel
P. 134
Chapter 4 Matrices and Determinants
2 – 1 0 – 3
A = – 1 10 – 1 (4.27)
4 0 3 – 2
– 3 0 0 1
Solution:
Using the above procedure, we will multiply each element of the first column by its cofactor.
Then,
–
–
–
–
10 1 – 1 03 – 1 03 – 1 03
A=2 03 2 – ( – 1 ) 0 3 2 +4 1 0 1 – ( – 3 ) 1 0 – 1
–
–
–
00 1 0 0 1 0 0 1 03 – 2
⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ ⎧ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎩ ⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ ⎧ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎩
a [] b [] c [] d []
Next, using the procedure of Example 4.5 or Example 4.8, we find
a [] = 6 , b[] = – 3 , c[] = 0 , d[] = – 36
and thus
–
detA = a [] + b [] + c [] + d [] = 63 + 036 = – 33
–
We can verify our answer with MATLAB as follows:
A=[ 2 −1 0 −3; −1 1 0 −1; 4 0 3 −2; −3 0 0 1]; delta = det(A)
delta =
-33
The MATLAB user−defined function file below can be used to compute the determinant of a
n × n matrix.
% This file computes the determinant of a nxn matrix
% It must be saved as function (user defined) file
% detnxn.m in the current Work Directory. Make sure
% that his directory is added to MATLAB's search
% path accessed from the Editor Window as File>Set Path>
% Add Folder. It is highly recommended that this
% function file is created in MATLAB's Editor Window.
%
function y=detnxn(A);
% The following statement initializes y
y=0;
% The following statement defines the size of the matrix A
[n,n]=size(A);
% MATLAB allows us to use the user-defined functions to be recursively
% called on themselves so we can call det2x2(A) for a 2x2 matrix,
% and det3x3(A) for a 3x3 matrix.
4−16 Numerical Analysis Using MATLAB® and Excel®, Third Edition
Copyright © Orchard Publications