The following shows how to use the symbolic toolbox to create the handle for the ODEs and then use ode45 to find a numerical solution.
syms t(y) x(y)
dt = diff(t);
ddt = diff(dt);
dx = diff(x);
ddx = diff(dx);
eq1 = ddt == dt^2*(tan(t)) - ddx*4*sec(t);
eq2 = dt^2*(sec(t)-tan(t)) == ddx*sec(t)*(1/0.625-4);
[eqn, vars] = reduceDifferentialOrder([eq1 eq2], [t x]);
[M,F] = massMatrixForm(eqn,vars);
f = M\F;
odeFun = odeFunction(f, vars);
ic = [pi/6; 0; 0; 0];
ode45(odeFun, [0 10], ic)
Alternatively, you can also write your own odeFunction but It require a bit of algebric manipulation
ode = @myodeFun;
t = [0 10];
ic = [pi/6; 0; 0; 0];
[t,y] = ode45(ode, t, ic);
plot(t,y, 'o-');
function dydx = myodeFun(t,x)
dydx = zeros(4,1);
dydx(1) = x(2);
dydx(2) = -(x(2)^2*(2*cos(x(1))*tan(x(1)) - 5))/(3*cos(x(1)));
dydx(3) = x(4);
dydx(4) = (5*x(2)^2*(cos(x(1))*tan(x(1)) - 1))/12;
end
Best Answer