11221 212211 212 12 1
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
fd
0 comentarios
Respuestas (1)
Jan
el 7 de Nov. de 2019
Editada: Jan
el 7 de Nov. de 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 comentarios
Steven Lord
el 7 de Nov. de 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.
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!