Link to home
Start Free TrialLog in
Avatar of crichtx
crichtx

asked on

determinant of a matrix

The determinant of a 3X3 matrixis
¿g h i¿ ¿¿
det( A) = aei + bfg + cdh - afh - bdi - ceg
¿a b c¿ A=¿d e f¿
¿¿
Think of this as being the sum of the products of each of the three elements in the three forward diagonals minus the sum of the products of each of the three elements in the backward diagonals. In the diagram below note how the first two columns of A are placed to the right of A. This makes the elements in the diagonals easy to see.
I need a MATLAB function mdet3( A ) that first checks to see if A is 3X3. If the matrix is not 3X3, call the MATLAB error function with the message ‘Matrix not 3X3’to stop the processing. If the matrix is 3X3 calculate and return the determinant according to the above formula 1.
Avatar of masheik
masheik
Flag of India image

To get matrix dim
You can use
[n_rows,n_col]=size(A)
Then check if row & col equals 3
If so it is 3*3 matrix
To find determinent of a square matrix just use
D = det(A)
ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial