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 Kommentar

madhan ravi
madhan ravi am 26 Okt. 2018
Maybe use numerical methods using ode solvers

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Stephan
Stephan am 25 Okt. 2018
Bearbeitet: Stephan am 25 Okt. 2018

0 Stimmen

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 am 25 Okt. 2018

0 Stimmen

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.

Produkte

Version

R2017b

Gefragt:

am 25 Okt. 2018

Kommentiert:

am 26 Okt. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by