Determinant with Laplace rule

조회 수: 7 (최근 30일)
Lorenzo Dursi
Lorenzo Dursi 2017년 1월 30일
편집: Jan 2017년 1월 30일
Hi! I have this Matlab code to calculate the determinant of a matrix with Laplace rule. But it sholud there be an error, because it doesn't work. Could someone help me?
function d = Laplace(A)
[~,n] = size(A);
if n == 1
d = A;
else
d = 0;
for j = 1:n
A1 = A(2:n, [1:j-1, j+1:n]);
d = d+(-1)^(j+1)*A(1,j)*Laplace(A1);
end
end
  댓글 수: 1
Jan
Jan 2017년 1월 30일
Please explain "it does not work" with any details. Do you get an error message or does the result differ from your expectations? Did you use the debugger already to examine, what's going on?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 1월 30일
편집: Jan 2017년 1월 30일
The code works for me and the result equals the answer obtained by Matlab's det considering rounding errors.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by