I am new to Matlab and this might seem very easy.
I have 2 matrices:
a = [1 1 1; 2 2 2 ; 3 3 3 ; 4 4 4 ; 5 5 5];
b = [4 4 4; 3 2 4 ; 1 5 7 ; 4 3 8 ; 2 4 7];
I wanted to calculate the determinant of each row of the two matrices added by a row of ones (a 3*3 matrix), and put all the determinants in another array. For example, first determinant (d(1)) would be from this matrix:
and the second one (d(2)) would be from this matrix:
and so on...
When I try this:
m = size(a,1);
ons = ones(m,3);
d = det([a(:,:) ; b(:,:) ; ons(:,:)]);
I get this error:
Error using det
Matrix must be square.
How can I calculate all the determinants at once without using loop?
7 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754130
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754130
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754132
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754132
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754163
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754163
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754333
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754333
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754527
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754527
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754552
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754552
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754609
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/484288-how-to-calculate-determinant-of-matrices-without-loop#comment_754609
Sign in to comment.