How to solve ODE
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
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.
Risposte (1)
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
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.
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!