How do I prepare the following ODE for ode45?

5 ビュー (過去 30 日間)
Sergio Manzetti
Sergio Manzetti 2018 年 2 月 20 日
コメント済み: Torsten 2018 年 3 月 9 日
Hello, I would like to solve the following ODE in ode45, but the example's on the site are not describing using higher order derivatives with non-linear terms.
The ODE is:
y''' = y(2+x^2)
initial conditions are: y(0)=0 y'(0)=0 y''(0)=0
Thanks!
  2 件のコメント
Torsten
Torsten 2018 年 2 月 20 日
Google is your friend:
matlab & higher order odes
Best wishes
Torsten.
Sergio Manzetti
Sergio Manzetti 2018 年 2 月 20 日
編集済み: Sergio Manzetti 2018 年 2 月 20 日
I got so far:
dYdX = @(X,Y) [Y(3) + (x^2+2)*Y(1)]; % Differential equation
res = @(ya,yb) [ya(1); ya(2); yb(2)-1]; % Boundary conditions
SolYinit = bvpinit([0 1E+1], [1; 1; 1]);
Fsol = bvp4c(dYdX, res, SolYinit);
X = Fsol.x;
F = Fsol.y;
figure(1)
plot(X, F)
legend('F_1', 'F_2', 'F_3', 3)
grid
But the first line is not correct. Can you see what is missing?

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

採用された回答

Torsten
Torsten 2018 年 2 月 20 日
fun = @(x,y)[y(2);y(3);y(1)*(2+x^2)];
y0 = [0 0 0];
xspan = [0 5];
[X,Y] = ode45(fun,xspan,y0);
plot(X,Y(:,1),X,Y(:,2),X,Y(:,3));
Best wishes
Torsten.
  17 件のコメント
Sergio Manzetti
Sergio Manzetti 2018 年 2 月 28 日
Hi Jan, is it possible to plot the square modulus of the numerical solution following your suggestion here ?
Torsten
Torsten 2018 年 2 月 28 日
Maybe, if you tell us what the "square modulus of the numerical solution" is.

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

その他の回答 (1 件)

Sergio Manzetti
Sergio Manzetti 2018 年 2 月 28 日
編集済み: Sergio Manzetti 2018 年 2 月 28 日
(abs(y))^2
if y is the solution
  11 件のコメント
Sergio Manzetti
Sergio Manzetti 2018 年 3 月 9 日
編集済み: Sergio Manzetti 2018 年 3 月 9 日
OK, this is quite a new way to think...so one lists the levels of derivation of y as such?
Torsten
Torsten 2018 年 3 月 9 日
You transform a higher order ODE to a system of first-order ODEs.
I already gave you the link to digest this.

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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by