Using recursive method for finding the determinant of a matrix
Show older comments
Hello, I'd like to find the determinant of a matrix without using built-in functions.
I thought of using cofactor expansion, and this is my code.
(I'm very new to this MATLAB programming, and I have very little knowledge about this part.)
I'm actually not sure if I could arrange the codes like that.
I could really use some help, please. Thank you for reading.
function det=myDet(A)
if size(A)==[2 2]
a_ij=A(i, j);
det=(a_11)*(a_22)-(a_12)*(a_21);
else
i=1:n;
A(:,1)=[];
A(i,:)=[];
A=A_i;
det=symsum((((-1)^(i+1))*myDet(A_i)),i,1,n)
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!