You will have a 4-element state vector instead of 2.
initial_cond = [1;1;0;0];
[t,y] = ode45(@(t,y)ODE_funct_fourth_order(t, y, m1, m2, L, k, g),tspan,initial_cond);
with
function dydt = ODE_funct_fourth_order(t, y, m1, m2, L, k, g)
dydt = [y(3);y(4);something;something];
end
where y is
y(1) = x
y(2) = theta
y(3) = xdot
y(4) = thetadot
You get the expressions for dydt(3) and dydt(4) by solving (e.g. on paper or inside your derivative function using backslash \ operator) your matrix equations for xdotdot and thetadotdot.
Best Answer