How to solve ODE

2 visualizzazioni (ultimi 30 giorni)
John Miller
John Miller il 27 Lug 2012
Hello,
I have following nonlinear ODE-System: G(x)*x'=0
How can I solve this ODE-System with respect to x'=f(x)
so I need f(x)...
Thank you!
  4 Commenti
Star Strider
Star Strider il 29 Lug 2012
Modificato: Star Strider il 29 Lug 2012
The ODE solvers don't have to have a square matrix argument, but the matrix argument does have to have as many rows as it has orders of derivatives, so that it is set up as a system of first-order ODEs. So if it's a second-degree ODE it has to have two rows, third-degree, three, etc. It definitely doesn't have to be square. For instance, the spring-mass-damper system:
mx" = u - k*x' - k2*x, where: x' = dx/dt, x" = d^2x/(dt^2)
is defined for ode45 as:
xdot(1) = x(2);
xdot(2) = -x(1)*k(2)/m -x(2)*k(1)/m + u(t)/m;
and works fine. I don't know if the Symbolic Math Toolbox can format your equations for you (you can ask it and find out), but I suggest it because it avoids algebra errors. If not, you can do it with pencil and paper.
John Miller
John Miller il 29 Lug 2012
" I don't know if the Symbolic Math Toolbox can format your equations for you (you can ask it and find out), "
How can I ask it? I have not much experience in MATLAB

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 29 Lug 2012
Modificato: Star Strider il 29 Lug 2012
I asked the Symbolic Math Toolbox and it suggested that I refer you to the odeToVectorField function: http://www.mathworks.com/help/toolbox/symbolic/odetovectorfield.html.
When I gave it this code for the ODE I listed above:
syms m x(t) u k1 k2
% Differential Equation: mx" = u - k1*x' - k2*x
[V,Y] = odeToVectorField(m*diff(x,2) == u - k1*diff(x,1) - k2*x)
it returned:
V =
Y[2]
-(k1*Y[2] - u + k2*Y[1])/m
Y =
x
Dx
The ‘V’ output is the argument you will give to your ODE function, and the ‘Y’ ouput are the substitutions it made. It assumes you know that on the left side of ‘V’ to put the vector:
Ydot(1)
Ydot(2)
if necessary, depending on how your format the equation you use as one of your ODE arguments. You don't have to, though. You can just give it the matrix. The ODE functions assume the rest.
  4 Commenti
John Miller
John Miller il 30 Lug 2012
Modificato: John Miller il 30 Lug 2012
"Did your matrix start out as a third-degree differential equation?" No
"but I cannot figure out where the y-vector came from or what it represents." y=[y(1); y(2); y(3)] are just the unknown variables like y1,y2,y3 or x,y,z or x1,x2,x3 y' is the first time derivative like y'=[dy1/dt; dy2/dt; dy3/dt]
Like I sad, I just want to bring the equation M*y'=0 ans M is like you sad: " You have a [2 x 3] matrix in nonlinear functions of [y(1), y(2), y(3)] " . And I want to bring this simple equation to the form y'=f(y) where f(y) is a vectorfield. Thats all I want to do.
Star Strider
Star Strider il 30 Lug 2012
The fundamental problem is that because your ‘M’ matrix is [2 x 3] and you have three unknowns, you have an under-determined system. There is no unique solution. That is the reason I suggested that you go back to the Symbolic Math Toolbox and start over.
I suggest that to you again.

Accedi per commentare.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by