You need to solve for all xdots simultaneously - this is done in matrix format below. There were also a number of errors in your equations. The following works:
tspan = [0 10];
x0=[0;0;0;0;0;0];
[t, x] = ode23(@fun_1, tspan, x0);
plot(t,x(:,3))
xlabel('t')
ylabel('theta(t)')
function f = fun_1(t,x)
m0 = 0.25; m1 = 0.1; m2= 0.08;
L1 = 0.25; L2 = 0.2;
g = 9.81;
F = sin(t);
k24 = ((L1*cos(x(3))*(m1+2*m2))/(2*(m0+m1+m2)));
k26 = ((m2*L2*cos(x(5)))/(2*(m0+m1+m2)));
k42 = ((6*L1*cos(x(3))*(m1+2*m2))/(4*L1^2*(m1+3*m2)));
k46 = ((6*m2*L1*L2*cos(x(3)-x(5)))/(4*L1^2*(m1+3*m2)));
k62 = ((6*m2*L2*cos(x(5)))/(4*m2*L2^2));
k64 = ((6*m2*L1*L2*cos(x(3)-x(5)))/(4*m2*L2^2));
M = [1 0 0 0 0 0;
0 1 0 k24 0 k26;
0 0 1 0 0 0;
0 k42 0 1 0 k46;
0 0 0 0 1 0;
0 k62 0 k64 0 1];
V = [x(2);
((L1*sin(x(3))*(m1+2*m2))/(2*(m0+m1+m2)))*x(4)^2+((m2*L2*sin(x(5)))/(2*(m0+m1+m2)))*x(6)^2+2*F/(2*(m0+m1+m2));
x(4);
-6*m2*L1*L2*sin(x(3)-x(5))/(4*L1^2*(m1+3*m2))*x(6)^2+6*g*L1*(m1+2*m2)*sin(x(3))/(4*L1^2*(m1+3*m2));
x(6);
6*m2*L1*L2*sin(x(3)-x(5))/(4*m2*L2^2)*x(4)^2 + 6*m2*g*L2*sin(x(5))/(4*m2*L2^2)];
f = M\V;
end
Best Answer