How to solve this ODE

5 vues (au cours des 30 derniers jours)
Parth Chansoria
Parth Chansoria le 25 Oct 2018
Commenté : madhan ravi le 26 Oct 2018
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 commentaire
madhan ravi
madhan ravi le 26 Oct 2018
Maybe use numerical methods using ode solvers

Connectez-vous pour commenter.

Réponses (2)

Stephan
Stephan le 25 Oct 2018
Modifié(e) : Stephan le 25 Oct 2018
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 le 25 Oct 2018
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.

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by