Secant method with two ODE's of degree 2 - matlab $$\frac{d^2r}{dt^2}-r\left(\frac{d\phi}{dt}\right)^2=G\cos\alpha-g\frac{R^2}{r^2}$$
$$r\frac{d^2\phi}{dt^2}+2\frac{dr}{dt}\frac{d\phi}{dt}=G\sin\alpha$$
The two ODE's above are given. I have written them as 4 ODE's of degree one and solved the equation with ODE45. 
I've plotted the graph and now I want to find where the equation intersects with the horizontal line $y=1$. I want to use the secant method becuase then i do not have to calculate the derivative of my equation. Normally I would just take: "my equation" = 1, but how do I do it in this case when I got two equations?
Thanks
 A: I'm going to assume you have converted from your polar coordinates to x-y coordinates.
In such a case, let y be the vector of $y$ values at each time step $t_i$. To find where $y$ is close to $1$, simply do the following:
[mn,idx] = min(abs(y-1));

This gives you the minimum absolute distance as well as the index of the element, stored in idx. You can then interpolate from the neighboring indices in whichever way you'd like.
A: Try this. (You will need to subtract 1 from your vector, because the function finds the zero crossing.index is supposed to be t vector in your case)
function [ out ] = VectorZero( index, vector )

out=[];
for i=1:length(index)-1

if(vector(i)*vector(i+1)<0)
    out=[out (index(i+1)*abs(vector(i))+index(i)*abs(vector(i+1)))/(abs(vector(i))+abs(vector(i+1)))];
end

if(vector(i)==0)
    out=[out index(i)];
end
end

I have written a few functions that find the index of min/max in a vector, finds the index of a value in a vector etc. Matlab doesn't seem to have a default function for things. Or maybe I didn't look hard enough.
