11221 212211 212 12 1

13 vues (au cours des 30 derniers jours)
Miguel Anliker
Miguel Anliker le 7 Nov 2019
fd

Réponses (1)

Jan
Jan le 7 Nov 2019
Modifié(e) : Jan le 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 commentaires
Miguel Anliker
Miguel Anliker le 7 Nov 2019
this was the code to call our function
Steven Lord
Steven Lord le 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Calendar dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by