function adjA=mnhf_adjoint(A) %MNHF_ADJOINT calculate adjoint of a (square) matrix % % A - the matrix in question % % Usage mnhf_adjoint(A); [r,c] = size(A); % Compute the size of A. if isequal(r,c) if r==1 fprintf('Matrix has dimension 1-by-1.') else % Initialize array. adjA = zeros(r,c); % Evaluate minors. for ii=1:r for jj=1:c % Split out cases where we know the row (column) number is 1 or r % (c). Use : notation to facilitate matrix index referencing. if ii==1 if jj==1 adjA(ii,jj) = mnhf_determinant(A(2:r,2:c)); elseif (jj>1 && jj1 && ii1 && jj1 && jj