• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# determinant de bois

a guest Feb 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function D=Determinant(A)
2. [m,n] = size(A);
3. if m~=n
4.     error('MATRIX MUST BE SQUARE')
5. elseif isequal(size(A),[4,4])
6.     D = A(1,1)*Determinant(ignoreRowAndCol(A,1,1))...
7.         - A(1,2)*(Determinant(ignoreRowAndCol(A,1,2))) ...
8.         + A(1,3)*(Determinant(ignoreRowAndCol(A,1,3))) ...
9.         - A(1,4)*(Determinant(ignoreRowAndCol(A,1,4)));
10.     return
11. elseif isequal(size(A),[3,3])
12.     D = A(1,1)*(Determinant(ignoreRowAndCol(A,1,1)))...
13.         - A(1,2)*(Determinant(ignoreRowAndCol(A,1,2))) ...
14.         + A(1,3)*(Determinant(ignoreRowAndCol(A,1,3)));
15.     return
16. elseif isequal(size(A),[2,2])
17.     D = (A(1,1)*A(2,2))-(A(1,2)*A(2,1));
18.     return
19. end
20. end
21.
22. function  B = ignoreRowAndCol(A,i,j)
23. A(i,:)=[];
24. A(:,j)=[];
25. B = A;
26. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top