Determinant with Laplace rule

8 visualizaciones (últimos 30 días)
Lorenzo Dursi
Lorenzo Dursi el 30 de En. de 2017
Editada: Jan el 30 de En. de 2017
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 comentario
Jan
Jan el 30 de En. de 2017
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?

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 30 de En. de 2017
Editada: Jan el 30 de En. de 2017
The code works for me and the result equals the answer obtained by Matlab's det considering rounding errors.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by