A =[5 4 2 1;7 1 6 2;4 2 3 1;5 5 6 8];
不可以用inv和det及反除 我目前卡在餘因子的地方?有位大大寫這樣
function C = cofactor(A, i, j)
% cofactor Matrix of cofactors.
%
% C = cofactor(A) returns the matrix of cofactors of A.
% If A is invertible, then inv(A) = C' / det(A).
%
% C = cofactor(A, i, j) returns the cofactor of
% row i, column j of A.
if nargin == 3
% Remove row i and column j to produce the minor.
M = A;
M(i, = [];
M(:,j) = [];
C = (-1)^(i+j) * det(M);
else
[n,n] = size(A);
for i = 1:n
for j = 1:n
C(i,j) = cofactor(A, i, j);
end
end
end
但nargin == 3 以及[n,n] = size(A); 這邊 我看不太懂 還望各位大大解答