11221 212211 212 12 1

조회 수: 12 (최근 30일)
Miguel Anliker
Miguel Anliker 2019년 11월 7일
편집: Miguel Anliker 2019년 11월 8일
fd

답변 (1개)

Jan
Jan 2019년 11월 7일
편집: Jan 2019년 11월 7일
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
Miguel Anliker
Miguel Anliker 2019년 11월 7일
this was the code to call our function
Steven Lord
Steven Lord 2019년 11월 7일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by