matrices dimensions ode45

11 visualizzazioni (ultimi 30 giorni)
christoforos Nicodemou
christoforos Nicodemou il 24 Nov 2019
Commentato: Pravin Jagtap il 27 Nov 2019
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 Commenti
Star Strider
Star Strider il 24 Nov 2019
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 il 27 Nov 2019
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

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by