Solve ODE with BC

2 ビュー (過去 30 日間)
Sergio Manzetti
Sergio Manzetti 2020 年 6 月 3 日
編集済み: Sergio Manzetti 2020 年 6 月 8 日
Hi, I would like to solve this ODE with initial conditions y=0 and y'=0, and boundary cond L=[0,1] using the given command:
syms x y(x)
% Define first and second derivatives for y
Dy = diff(y,x);
% Define differential equation
Diff = (1i*diff(y,x)-x)^2+x^2 == 0.326307*y;
% Set initial conditions
y = y(0) == 0;
Dy = diff(y,0) == 0;
% Solve differential equation and display
Uc_sym = dsolve(Diff, y, Dy);
display(['y = ',char(10),char(Uc_sym),char(10)])
Alternatively, check out this example in the documentation.
But I am not aware on how to include the BCs and how to make this script work at all.. Can someone help?
Thanks

採用された回答

Stephan
Stephan 2020 年 6 月 3 日
編集済み: Stephan 2020 年 6 月 3 日
I doubt that your ode has an analytical solution - however here is a minimal working example of how to include BC's in a symbolic way:
syms y(x)
% Define first derivative for y
Dy = diff(y,x);
% Define differential equation
ode = y == Dy * x;
% Set conditions
conds = [y(0)==0, y(1)==2, Dy(0)==2, Dy(1)==2];
% Solve differential equation and display
sol = dsolve(ode, conds)
If you dont find an analytical solution use bvp4c instead to solve numeric.
  1 件のコメント
Sergio Manzetti
Sergio Manzetti 2020 年 6 月 8 日
編集済み: Sergio Manzetti 2020 年 6 月 8 日
Thanks! Seems solving this problem with bvp4c is not easy at all, although the problem here and the BC conditions are quite straight forward presented.

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

その他の回答 (0 件)

カテゴリ

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