MATLAB: Dsolve unable to find symbolic solution to second-order ODE

dsolveode

Hi all,
I have been trying my hand at matlab recently and encountered an error while attempting to solve an ordinary differential equation. The equation I am trying to solve for is
, where and values for g and R are 9.8 and 5 respectively. The system starts at rest () and with an initial angle . The code I have produces thus far is:
syms f(t)
g=9.8
R=5
Df = diff(f,t)
ode = diff(f,t,2) == -g/R*sin(f)
cond1 = f(0)==20
cond2 = Df(0)==0
conds = [cond1 cond2]
dsolve(ode,conds)
When I attempt to execute the code, however, I recieve an error that dsolve in unable to find a symbolic solution (line 209). Would anybody be able to advise me on how to proceed around this? Thanks!

Best Answer

Since there is a nonlinear term in the ODE, I am not sure if a symbolic solution is possible. Following code shows how to get a numerical solution using ode45()
syms f(t)
g=9.8;
R=5;
Df = diff(f,t);
ode = diff(f,t,2) == -g/R*sin(f);
ode2 = odeToVectorField(ode);
odeFun = matlabFunction(ode2, 'Vars', {'t', 'Y'});
ic = [20; 0];
tspan = [0 10];
[t, y] = ode45(odeFun, tspan, ic);
plot(t, y);
legend({'y', 'dot\_y'}, 'Location', 'best')