Shooting method for boundary value problems

6 ビュー (過去 30 日間)
Aaditya
Aaditya 2019 年 3 月 11 日
回答済み: Basavaraj 2024 年 10 月 29 日
I use ODE45 and the shooting method to solve boundary value problems. There was a specific case in second order differential equations, where an unknown initial condition (which is to be found using shooting method) is a part of the expression of the second derivative, something like the following code. I want to know how to include it in the function and do I need to use any looping statements for it.
funtion dy = diffe(x,y)
l = 2;
p = 3;
dy = [y(2); p*x^2+2*y(1)+y0];
end
So in this code, value of dy/dx at x=0 is known but the value of y at x=0 is not known, but the value of y at x=1 (second boundary is known). This function is to be called like this:
funtion odesolver
dy0 = 0;
[x,y] = ode45(@diffe, [0 1], [y0, dy0]);
end
If someone can recommend a solution to this, that'll be very helpful.
  1 件のコメント
Torsten
Torsten 2019 年 3 月 11 日
Use BVP4C instead of ODE45.

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

回答 (1 件)

Basavaraj
Basavaraj 2024 年 10 月 29 日
funtion dy = diffe(x,y)
l = 2;
p = 3;
dy = [y(2); p*x^2+2*y(1)+y0];
end
funtion odesolver
dy0 = 0;
[x,y] = ode45(@diffe, [0 1], [y0, dy0]);
end

カテゴリ

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