Simulink function giving an error of incorrect dimensions of matrix multiplication. Using MATLAB 2021b.

1 vue (au cours des 30 derniers jours)
function op = fcn(ip)
mass =5 ; % mass of block
x = 0.3; y = 0.2; z = 0.1; % dimensions of block
Jx = (mass / 12) * (y^2 + z^2);
Jy = (mass / 12) * (x^2 + z^2);
Jz = (mass / 12) * (x^2 + y^2);
Jxz = 0;
J = [Jx 0 -Jxz; 0 Jy 0; -Jxz 0 Jz];
% Parse Input
OMG = ip(1:3) ;
EUL = ip(4:6) ;
TRQ = ip(7:9);
P_hi = EUL(1);
t_heta = EUL(2);
p_si = EUL(3);
P = OMG(1);
Q = OMG(2);
R = OMG(3);
OMGG = [0 -R Q; R 0 P; -Q P 0];
H = [1 tan(t_heta)*sin(P_hi) tan(t_heta)*cos(P_hi);
0 cos(P_hi) -sin(P_hi);
0 sin(P_hi)/cos(t_heta) cos(P_hi)/cos(t_heta)];
EUL_dot = H*OMG;
OMG_dot = J\ (TRQ - OMGG*J*OMG);
op = [OMG_dot; EUL_dot];
end
ERROR. Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
  8 commentaires
John
John le 8 Août 2023
i have performed all these steps, but stil same error. All matrices sizes are perfect as per the multiplication laws of matrices. still giving error:
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Function 'MATLAB Function' (#249.797.804), line 33, column 15: "H * OMG" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Function 'MATLAB Function' (#249.839.846), line 34, column 34: "J * OMG" Launch diagnostic report.
is it some MATLAB Version error or what

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by