I am putting down the simplified code snippet-
IC = [0.01 1.2]; options = odeset(\'Events\', @heavi); [x,y] = ode45(@(x,y) F(x,y),xspan,IC,options); function