syms x(t) y(t) T(t) m r g
eqn1 = m*diff(x(t), 2) == T(t)/r*x(t);
eqn2 = m*diff(y(t), 2) == T(t)/r*y(t) - m*g;
eqn3 = x(t)^2 + y(t)^2 == r^2;
vars = [x(t); y(t); T(t)];
[eqns,vars] = reduceDifferentialOrder(eqns,vars)
eqns =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768399/image.png)
vars =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768404/image.png)
[DAEs,DAEvars] = reduceDAEIndex(eqns,vars)
DAEs =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768409/image.png)
DAEvars =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768414/image.png)
[DAEs,DAEvars] = reduceRedundancies(DAEs,DAEvars)
DAEs =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768419/image.png)
DAEvars =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768424/image.png)
[M,f] = massMatrixForm(DAEs,DAEvars)
M =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768429/image.png)
f =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768434/image.png)
pDAEvars = symvar(DAEvars);
extraParams = setdiff(pDAEs, pDAEvars)
extraParams = ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1768439/image.png)
M = odeFunction(M, DAEvars);
f = odeFunction(f, DAEvars, g, m, r);
F = @(t, Y) f(t, Y, g, m, r);
y0est = [r*sin(pi/6); -r*cos(pi/6); 0; 0; 0; 0; 0];
opt = odeset('Mass', M, 'InitialSlope', yp0est);
implicitDAE = @(t,y,yp) M(t,y)*yp - F(t,y);
[y0, yp0] = decic(implicitDAE, 0, y0est, [], yp0est, [], opt);
opt = odeset(opt, 'InitialSlope', yp0);
[tSol,ySol] = ode15s(F, [0, 1.5], y0, opt);
plot(tSol,ySol(:,1:origVars-1))
legend(S, 'Location', 'Best');