Runge Kutta solving differential equations
2 次查看(过去 30 天)
显示 更早的评论
Hello everyone!
I have to solve this second order differential equation by using the Runge-Kutta method in matlab:
can anyone help me please? and how can i plot the figure?(a against e)
d2a/de2=(((((2+c2)*(Fu^2))/(1+c2))+1)*(a^c2)-((2+c2/1+c2)*(Fu^2/a))-a^(2+(2*c2)))/(((2+c2)*Fu^2)/(1+c2)*(3+c2));
Fu=1
c2=0 , 0.5 , 1 (there are 3 values for c2)
initial conditions are: a=0.8 , d_a=0
4 个评论
Alan Stevens
2020-11-7
I have not generated any code. If you look at the ode45 help file you will see explanations of what to do.
回答(1 个)
Samuele Sandrini
2020-11-7
编辑:Samuele Sandrini
2020-11-7
Hi, i'm sorry but your differential equation is unreadable in that way.
However i try to give you all element that you need; as already told by @Alan Stevens, first of all you have to pass from a second order diff. eq. to a system of two first order diff. equation, in this way:
- starting from your second order equation, in general like this:
, you take two auxiliary variable
and
.
- After that you can rewrite the first equation like:
Note that the first equation in the system is always the same, the second one corrispond to y'' and is equal to the starting equation where y and y' is replaced by
e
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/406145/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/406150/image.png)
Once you obtained the system, programmaticaly you can do something like this:
f = @(z,t) [z(2); ...(the second eqn in the system using z(1) end z(2)) ];
[t,y] = ode45(f,[t0 tF],[y(0);y'(0)]) %where y(0) and y'(0) are the initial condition (in your case [0.8;0])
Note that y will be a matrix with two column that corrispond respectively to
and
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/406130/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/406135/image.png)
If you want an example here you can find in Examples paragraph, the second one is the solution of the van der Pol equation that is similar to this procedure.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!