Page 128 - Numerical Analysis Using MATLAB and Excel
P. 128
Chapter 4 Matrices and Determinants
Then,
detA = a a – a a (4.14)
11 22
21 12
Example 4.4
Given that
A = 12 and B = 2 – 1
34 2 0
compute detA and detB .
Solution:
⋅
⋅
–
detA = 1 4 32 = 46 = – 2
–
)
⋅
)
–
detA = 2 0 2 ( ⋅ – 1 = 0 – – ( 2 = 2
Check with MATLAB:
A=[1 2; 3 4]; B=[2 −1; 2 0]; % Define matrices A and B
det(A) % Compute the determinant of A
ans =
-2
det(B) % Compute the determinant of B
ans =
2
While MATLAB has the built−in function det(A) for computing the determinant of a matrix A,
this function is not included in the MATLAB Run−Time Function Library List that is used with
*
the Simulink Embedded MATLAB Function block. The MATLAB user−defined function file
below can be used to compute the determinant of a 2 × 2 matrix.
% This file computes the determinant of a 2x2 matrix
% It must be saved as function (user defined) file
% det2x2.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=det2x2(A);
* For an example using this block, please refer to Introduction to Simulink with Engineering Applications, ISBN
0−9744239−7−1, Page 16−3.
4−10 Numerical Analysis Using MATLAB® and Excel®, Third Edition
Copyright © Orchard Publications