matrices dimensions ode45

조회 수: 11 (최근 30일)
christoforos Nicodemou
christoforos Nicodemou 2019년 11월 24일
댓글: Pravin Jagtap 2019년 11월 27일
hello
i want to solve an ode45 equation
this is the equation
xdot=[[ x(2) ; x(2).^2*[R12*m2*[-R12x_*sin(x(1)+f12)+R12y_*cos(x(1)+f12)]+a*m3*[-R23x_*sin(x(1))+R23y_*cos(x(1))]] +...
w3_.^2*[-R23*m3*[-R23x_*sin(th3_+f23)+R23y_*cos(th3_+f23)]]+...
a3_*[R23*m3*[R23x_*sin(th3_+f23)+R23y_*cos(th3_+f23)]]+...
[Ffr1y_-F32y_]*R12x_+[Ffr1x_+F32x_]*R12y_+[-F43y_-Fpy]*R32x_+[F43x_+Fpx]*R32y_+T12__]/...
[Ig2-[R12*m2*[cos(x(1)+f12)*R12x_+R12y_*sin(x(1)+f12)]+m3*a*[-R32x_*cos(x(1))+R32y_*sin(x(1))]]]];
all the variables are 1*1 arrays and there are some scalar lg2,m2,m3
but when i run it i get the error Dimensions of matrices being concatenated are not consistent
  댓글 수: 2
Star Strider
Star Strider 2019년 11월 24일
Please edit your code to make it readable. Even when I format it, I cannot understand what you are doing with it, and I am sure MATLAB is having the same problem. Also, other than the square brackets that enclose the matrix, use parentheses, not square brackets, within the matrix. It is easier to read, and less subject to error. I would also avoid using continuation ellipses, since MATLAB will then assume those are supposed to be single lines.
The numeric ODE solvers require that your ODE function return a column vector. The easiest way to assure that is to provide all the constants and a random vector for ‘x’. When MATLAB can understand it outsiide of any ODE solver and produce a column vector from it, you can use the ODE solvers with it.
Pravin Jagtap
Pravin Jagtap 2019년 11월 27일
As mentioned by Star Strider, please provide the ODE which you want solve along with initial condition so that we can understand your code and issue in detail.
~Pravin

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by