How to solve this ODE

5 ビュー (過去 30 日間)
Parth Chansoria
Parth Chansoria 2018 年 10 月 25 日
コメント済み: madhan ravi 2018 年 10 月 26 日
I'm trying to solve the ODE A*(y'') + B*sin(C*y) + D(y') = 0 where y depends on t, y' is dy/dt and y'' is d2y/dt2, and it has the initial condition y(t=0)=E and y'(t=0)=0. I have formulated the following code:
syms y(t) A B C D E
Dy= diff(y,t);
D2y= diff(y,t,2);
ode = A*D2y + B*sin(C*y) + D*Dy == 0;
cond = y(0)== E;
cond2 = Dy(0)==0;
ySol(t) = simplify(dsolve(ode,conds))
The output says unable to find explicit solution. I'm unsure what to do further to solve it.
  1 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 26 日
Maybe use numerical methods using ode solvers

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

回答 (2 件)

Stephan
Stephan 2018 年 10 月 25 日
編集済み: Stephan 2018 年 10 月 25 日
Hi,
numeric solution you get by choosing values for A-D and the initial conditions. Then use for example:
syms y(t)
A = 5;
B = 1.5;
C= 3;
D = 25;
ode = A*diff(y,t,2) + B*sin(C*y) + D*diff(y,t) == 0;
[odes, vars] = odeToVectorField(ode);
odefun = matlabFunction(odes,'Vars',{'t','Y'});
y0=[-5 3];
tspan = [0 3];
[t, ySol] = ode45(odefun,tspan,y0);
plot(t,ySol(:,1),t,ySol(:,2))
Note that, since this is a second order ode you need 2 initial conditions for y(t) and Dy(t).
Best regards
Stephan

Star Strider
Star Strider 2018 年 10 月 25 日
Your function is nonlinear, and most nonlinear ODES do not have analytical solutions.
Try this:
syms y(t) A B C D E Y
Dy= diff(y,t);
D2y= diff(y,t,2);
ode = A*D2y + B*sin(C*y) + D*Dy == 0;
[VF,Subs] = odeToVectorField(ode)
odefcn = matlabFunction(VF, 'Vars',{t, Y, A, B, C, D, E})
Then provide numerical values for the constants (A, B, C, D, E), and use it as an argument to one of the numeric ODE solvers, for example:
tspan = [0 42];
Y0 = [0, 1];
[T,Y] = ode45(@(t,Y)odefcn(t, Y,A, B, C, D, E), tspan, Y0)
You may need a ‘stiff’ solver, such as ode15s, if the constants have widely-varying magnitudes.

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by