Simulink function giving an error of incorrect dimensions of matrix multiplication. Using MATLAB 2021b.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!