ode45 with two 2nd order differential equation

1.PNG
Here I have two differential equations and I want to solve it using ode45
2.PNG
I am asked to convert the two 2nd order equations to 4 first-order equations which are suitable for ode45.

回答 (5 件)

Steven Lord
Steven Lord 2019 年 5 月 11 日

0 投票

See the Higher-Order ODEs example on this documentation page and use the technique it illustrates to turn your system of two second order ODEs into a system of four first order ODEs.
Pulkit Gahlot
Pulkit Gahlot 2020 年 5 月 19 日

0 投票

'first make the function file'
function xval = pulfun(t,y)
%constant
u=0.012277471;
%define dy/dt
xval(1,1)=y(3);
xval(2,1)=y(4);
xval(3,1)=y(1)+2*y(4)-(1-u)*(y(1)+u)/((y(1)+u)^2+y(2)^2)^(1.5)-u*(y(1)-1+u)/((y(1)-1+u)^2+y(2)^2)^(1.5);
xval(4,1)=y(2)-2*y(3)-(1-u)*y(2)/((y(1)+u)^2+y(2)^2)^(1.5)-u*(y(2))/((y(1)-1+u)^2+y(2)^2)^(1.5);
end
'(then write a script file for use of ode45)'
y0=[0.994;0;0;-2.00158];
tspan=[10 40];
[tsol,ysol]=ode45(@(t,y) pulfun(t,y),tspan,y0);
plot(tsol,ysol)
i used my own terms. You can use your.

1 件のコメント

darova
darova 2020 年 5 月 19 日
Better be to separate and to make expressions clearer

サインインしてコメントする。

Stephane Sarrete
Stephane Sarrete 2020 年 11 月 21 日

0 投票

Hello,
Please, I don't understand what the y (1), y (2), y (3) and y (4) represent in the function definition. Can be stupid question but I really do not understand. Thank you for helping me.

1 件のコメント

Stephan
Stephan 2020 年 11 月 21 日
Since 2 ode of order 2 are transformed into 4 ode of order 1, the 4 different entries of the y-vector represent the 4 four unknowns, to solve for.

サインインしてコメントする。

Stephane Sarrete
Stephane Sarrete 2020 年 11 月 21 日

0 投票

Thanks so much for the help, I'll think about it.

カテゴリ

質問済み:

2019 年 5 月 11 日

回答済み:

2020 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by