title: How to use ODE45 to solve for a system of differential equations with a difficult end condition?
body: <p>My system of equations can be written down as-</p>
  <blockquote>
  <p>y1' = F_1(x,y1,y2)</p>
  </blockquote>
  <blockquote>
  <p>y2' = F_2(x,y1,y2)</p>
  </blockquote>
  <p>where F1 and F2 are some functions of x, y1, y2. y1 and y2 are functions of x and y1'=dy1_dx and y2'=dy2_dx.</p>
  <p>The initial condition is at x=0, y1=y2=0. However I need the solution at y1=1, i.e. as soon as y1=1 is reached, the iteration needs to stop. I want to solve it using a proper solver like ODE45 or ODE15s in MATLAB. However I am not sure how to set the x_span i.e. initial and final values of x. Please guide me.</p>
  <p>Note that, setting x at a large value say 1000 will not help, because I don't know where y1=1.</p>