MATLAB Answers

0

11221 212211 212 12 1

Asked by Miguel Anliker on 7 Nov 2019
Latest activity Edited by Miguel Anliker on 8 Nov 2019
fd

  0 Comments

Sign in to comment.

1 Answer

Jan
Answer by Jan
on 7 Nov 2019
Edited by Jan
on 7 Nov 2019

Please post an exact copy of the error message in the forum. A rough paraphrasing will hide important details. Thanks.
I assume the error message tells you, that you did not call this function with an input argument. How did you start the code? Using the "Run" button? Then no input is provided.
A simplification of your code:
function [determinant , inverse ] = invanddet3by3(A)
%INVANDDET3BY3 Calculates the determinant and the inverse of a 3 X 3 matrix by using cofactors and adjoint matrix
A11 = invanddet2by2sol(A([2,3], [2,3])); % Cofactors 3x3 matrix A
A12 = -invanddet2by2sol(A([2,3], [1,3]));
A13 = invanddet2by2sol(A([2,3], [1,2]));
A21 = -invanddet2by2sol(A([1,3], [2,3]));
A22 = invanddet2by2sol(A([1,3], [1,3]));
A23 = -invanddet2by2sol(A([1,3], [1,2]));
A31 = invanddet2by2sol(A([1,2], [2,3]));
A32 = -invanddet2by2sol(A([1,2], [1,3]));
A33 = invanddet2by2sol(A([1,2], [1,2]));
J = [ A11 A12 A13; A21 A22 A23; A31 A32 A33]; % Adjugate Matrix
determinant = A(1,1) * A11 + A(1,2) * A12 + A(1,3) * A13; % Determinant of A
if determinant ~= 0
inverse = J' / determinant; % Inverse of A
else
inverse=[];
end
end

  4 Comments

Show 1 older comment
invanddet3by3(invandet2by2sol(A))
J = [ A11 A12 A13; A21 A22 A23; A31 A32 A33]
this was the code to call our function
Steven Lord
on 7 Nov 2019
How was A defined before you executed this line of code?
invanddet3by3(invandet2by2sol(A))
If it hadn't been defined before you executed that line, MATLAB can't know what matrix you want to pass into the invanddet2by2sol function.

Sign in to comment.