How can I solve this 12x12 system of odes using any solver (i used ode45) without "Dimensions of matrices being concatenated are not consistent" error??

1 次查看(过去 30 天)
i used the code below in matlab but giving errors, how can solve it?
f = @(t,v)[ -v(5)*v(3) + v(6)*v(2) -g*sin(v(7)) + g*sin(v(7)) + Xu*(v(1) - u0) + Xw*(v(3) - w0);
v(4)*v(3) -v(6)*v(1) + g*cos(v(7))*sin(v(8)) + -g*cos(v(7))*sin(v(8)) + Yv*(v(2) - v0);
v(5)*v(1) -v(4)*v(2) + g*cos(v(7))*cos(v(8)) + -g*cos(v(7))*cos(v(8)) + Zu*(v(1) - u0) + Zw*(v(3) - w0);
(v(5)*v(6)*(Iyy - Izz) + Ixz*v(4)*v(5) + Ixz*((v(4)*v(5)*(Ixx - Iyy) - Ixz*v(5)*v(6)*Ixx + v(5)*v(6)*(Iyy - Izz) + Ixz*v(4)*v(5)*Ixz)/(Izz*Ixx - Ixz^2)))/Ixx;
(M + v(6)*v(4)*(Izz - Ixx) + Ixz*((v(6))^2 - (v(4))^2))/Iyy;
(v(4)*v(5)*(Ixx - Iyy) - Ixz*v(5)*v(6)*Ixx + v(5)*v(6)*(Iyy - Izz) + Ixz*v(4)*v(5)*Ixz)/(Izz*Ixx - Ixz^2);
v(5)*cos(v(8)) - v(6)*sin(v(8)) + 0*sin(v(9));
v(4) + v(5)*sin(v(8))*tan(v(8)) + v(6)*cos(v(8))*tan(v(8));
(v(5)*sin(v(8)) + v(6)*cos(v(8)))/cos(v(7));
(v(1) - u0)/v(4);
(v(2) - v0)/v(5);
(v(3) - w0)/v(6)];
[t,va] = ode45(f,[0 100],[u0 v0 w0 p0 q0 r0 theta0 phi0 Lphi0 rx0 ry0 rz0]);
it gives the error below;
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in
@(t,v)[-v(5)*v(3)+v(6)*v(2),-g*sin(v(7))+g*sin(v(7))+Xu*(v(1)-u0)+Xw*(v(3)-w0);v(4)*v(3),-v(6)*v(1)+g*cos(v(7))*sin(v(8))+-g*cos(v(7))*sin(v(8))+Yv*(v(2)-v0);v(5)*v(1),-v(4)*v(2)+g*cos(v(7))*cos(v(8))+-g*cos(v(7))*cos(v(8))+Zu*(v(1)-u0)+Zw*(v(3)-w0);(v(5)*v(6)*(Iyy-Izz)+Ixz*v(4)*v(5)+Ixz*((v(4)*v(5)*(Ixx-Iyy)-Ixz*v(5)*v(6)*Ixx+v(5)*v(6)*(Iyy-Izz)+Ixz*v(4)*v(5)*Ixz)/(Izz*Ixx-Ixz^2)))/Ixx;(M+v(6)*v(4)*(Izz-Ixx)+Ixz*((v(6))^2-(v(4))^2))/Iyy;(v(4)*v(5)*(Ixx-Iyy)-Ixz*v(5)*v(6)*Ixx+v(5)*v(6)*(Iyy-Izz)+Ixz*v(4)*v(5)*Ixz)/(Izz*Ixx-Ixz^2);v(5)*cos(v(8))-v(6)*sin(v(8))+0*sin(v(9));v(4)+v(5)*sin(v(8))*tan(v(8))+v(6)*cos(v(8))*tan(v(8));(v(5)*sin(v(8))+v(6)*cos(v(8)))/cos(v(7));(v(1)-u0)/v(4);(v(2)-v0)/v(5);(v(3)-w0)/v(6)]
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
  1 个评论
kayemba luwaga
kayemba luwaga 2021-1-28
eeeeh, I got the solution from an example in the link below before anyone answered! (i unconsistently used space between "-" operators). Thanks to those who were willing to help me out, anyway...........
https://www.reddit.com/r/matlab/comments/8m29ru/dimensions_of_matrices_being_concatenated_are_not/

请先登录,再进行评论。

回答(1 个)

Kayemba Luwaga
Kayemba Luwaga 2022-7-4
I got the solution from an example in the link below before anyone answered! (inconsistent spacing between "-" operators).
https://www.reddit.com/r/matlab/comments/8m29ru/dimensions_of_matrices_being_concatenated_are_not/

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by