why in this function they use empty square brackets?
Mostrar comentarios más antiguos
and how exactly this is solving the determinant, I don't completley understand what they did here/
sorry if it's a dumb question I'm new to coding and to matlab.
function det = myDet(A)
if isscalar(A)
det = A;
return
end
det = 0;
top_row = A(1,:);
A(1,:) = [];
for i = 1:size(A,2) % number of columns
A_i = A;
A_i(:,i) = [];
det = det+(-1)^(i+1)*top_row(i)*myDet(A_i);
end
end
Respuesta aceptada
Más respuestas (2)
In this context, it appears to be deleting elements from A.
Try it out in MATLAB to see what it is doing.
A = rand(3)
A(1,:)=[]
1 comentario
Almog Na
el 14 de Nov. de 2021
A(i,:) = [];
This deletes the i.th row of the matrix A.
Example:
A = [1,2,3; 4,5,6; 7,8,9];
A(1, :) = []
% A = [4,5,6; 7,8,9]
1 comentario
Almog Na
el 14 de Nov. de 2021
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!