How to solve this ODE

조회 수: 23 (최근 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 CenterFile Exchange에서 Numerical 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