Solving 2 second order differential equations

Hi, I'm trying to solve two simultaneous differential equations in matlab following the code provided here https://uk.mathworks.com/matlabcentral/answers/425468-how-to-solve-simultaneous-second-order-differential-equations . This is the code I have managed to producde so far
syms theta1(t) theta2(t) Dtheta1(t) Dtheta2(t)
g=9.81;
m1=1;
m2=1;
L1=1;
L2=1;
ode1= (-g*(2*m1+m2)*sin(theta1)-m2*g*sin(theta1-2*theta2)-2*sin(theta1-theta2)*m2*(Dtheta2^2*L2+Dtheta1^2*L1*cos(theta1-theta2)))/(L1*(2*m1+m2-m2*cos(2*theta1-2*theta2)));
[ode1, var1] = reduceDifferentialOrder(ode1,theta1);
ode2= (2*sin(theta1-theta2)*Dtheta1^2*L1*(m1+m2)+g*(m1+m2)*cos(theta1)+Dtheta2^2*L2*m2*cos(theta1-theta2))/(L2*(2*m1+m2-m2*cos(2*theta1-2*theta2)));
[ode2, var2] =reduceDifferentialOrder(ode2,theta2);
ode = [ode1; ode2;];
var = [var1; var2;];
[odes, vars] = odeToVectorField(ode);
ode_fun = matlabFunction(odes, 'Vars',{'t','Y'});
y0 = [0 0 0 0 0 0];
tspan = [0 15];
[t,y] = ode45(ode_fun,tspan,y0);
Dtheta1 = y(:,1);
theta1 = y(:,2);
Dtheta2 = y(:,3);
theta2 = y(:,4);
However, I am recieving multiple error messages Error messages.png
Any help on how to proceed from here would be greatly appreciated

类别

Community Treasure Hunt

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

Start Hunting!

Translated by