How to solve this ODE

4 visualizzazioni (ultimi 30 giorni)
Parth Chansoria
Parth Chansoria il 25 Ott 2018
Commentato: madhan ravi il 26 Ott 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 Commento
madhan ravi
madhan ravi il 26 Ott 2018
Maybe use numerical methods using ode solvers

Accedi per commentare.

Risposte (2)

Stephan
Stephan il 25 Ott 2018
Modificato: Stephan il 25 Ott 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 il 25 Ott 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.

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by