it might be a good idea to go back to the original derivation for this system. Instead of that, you can rewrite this as a matrix equation
[(M+m) m*sin(theta) m*r*cos(theta)] [ y''] [A1]
[ m*sin(theta) m 0 ] [ r''] = [A2]
[ m*cos(thea) 0 m*r ] [theta''] [A3]
where the notation means matrix * column vector = column vector. Each row corresponds to an equation and says that some combination of y'',r'',theta'' equals some other terms. Here A1 is the sum of all the stuff in eqn 1 not involving y'',r'',theta'', taken over to the right hand side. SImilarly for A2 and A3. Each of A1,A2,A3 might involve y,y',r,r',theta,theta'.
For the input to ode45, y,r, and theta are presumed known. Three of the required ode45 equations are
so the state variables are effectively known. This means that A1,A2,A3 and the matrix are all known. Denoting the matrix as B, then
and the last three required equations are