syms phi1(t) phi2(t)
g = 9.8;
m = 1;
k = 1;
c = 1;
l = 1;
l0 = 0.75;
dphi1=diff(phi1,t);
dphi2=diff(phi2,t);
eq1 = -(m * g * l * sind(phi1) + k * (l0^2) * cosd(phi1) * (sind(phi1) - sind(phi2)) + c * (l0^2) * cos(phi1) * (cos(phi1) * dphi1 - cosd(phi2) * dphi2))/(m * (l^2)) == diff(phi1, t ,2);
eq2 = -(m * g * l * sind(phi2) - k * (l0^2) * cosd(phi2) * (sind(phi1) - sind(phi2)) - c * (l0^2) * cos(phi2) * (cos(phi1) * dphi1 - cosd(phi2) * dphi2))/(m * (l^2)) == diff(phi2, t ,2);
vars = [phi1(t) ; phi2(t)]
V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,'vars', {'t','Y'})
interval = [0 1.5];
y0 = [8 0 -4 0];
ySol = ode45(M,interval,y0);
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1);
plot(tValues,yValues)
Best Answer