How to solve this system of differential equations with runge kutta method or with any other method on matlab?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
3 Kommentare
John D'Errico
am 18 Apr. 2023
Bearbeitet: John D'Errico
am 18 Apr. 2023
Please learn to use comments, not answers to make a comment.
x is one of the unknowns. Can you not cube it? I'm pretty sure that x.^3 cubes a number, but perhaps you have a really old version of MATLAB, when cubes had not yet been invented. ;-)
And, yes, you have the cube of a derivative. But again, IF you read the help as I have told you to do multiple times now, you would see that it just becomes one of the unknowns.
doc ode45
Seriously. Did you read the help for ODE45? Did you look at the examples?
I would strongly suggest you try using a tool like ODE45 on a SIMPLE problem. Learn to use it.
Next, READ the help for ODE45, AGAIN. In there, they explicitly show you how to solve a second order ODE, doing so by turning it into a pair of first order ODEs. You have two second order ODEs. So you will have a system of 4 ODEs. That they are not linear ODEs is not a problem. Nothing in the code for ODE45 requires the ODE be linear.
Antworten (1)
Yash
am 15 Nov. 2023
Hi Giannis,
I understand that you are interested in solving a system of Ordinary Differential Equations (ODEs) using MATLAB. To solve the equations, you can follow these steps:
- Determine the initial conditions: Since you are dealing with second-order differential equations, you will typically need two initial conditions for each variable. For example, x1(0) = 0, dx1/dt(0) = 0, x2(0), and dx2/dt(0).
- Choose a method: If you specifically want to use the Runge-Kutta method, there is no built-in function for that in MATLAB. You will need to implement your own logic. However, if you are open to using other methods, you can directly use the "dsolve" function to solve the system of differential equations. Refer to the following link for the documentation: https://www.mathworks.com/help/symbolic/dsolve.html
Given below is an example using the "dsolve" function:
syms y(t) a
eqn = diff(y,t) == a*y;
cond = y(0) == 5;
ySol(t) = dsolve(eqn,cond)
This example solves the differential equation "dy/dt = a*y" with the initial condition "y(0) = 5". The solution is stored in the symbolic expression "ySol(t)".
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Equation Solving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!