###
Poincaré maps in CL/SMALL>_MATCONT

When computing an orbit in Matlab an event can be defined as going through a zero of a given scalar function If does not explicitly depend on time in an autonomous dynamical system, this feature can be used to detect Poincaré intersections. One does this by setting the Events property to a function handle, e.g. `@events`, creating a function `[value,isterminal,direction] = events(t,y)` and calling

`[t,Y,TE,YE,IE] = solver(odefun,tspan,y0,options)`.

For the -th event function:

- `value(i)` is the value of the function.
- `isterminal(i)` = 1 if the integration is to terminate at a zero of this event function and 0 otherwise.
- `direction(i)` = 0 if all zeros are to be computed (the default), +1 if only the zeros are needed where the event function increases, and -1 if only the zeros where the event function decreases.

Corresponding entries in `TE, YE`, and `IE` return, respectively, the time at which an event occurs, the solution at the time of the event, and the index of the event function that vanishes.

Example

Let a set of two event functions be introduced by defining the function `t`estEV:

    function [value,isterminal,direction]= testEV(t,y,varargin)
    value=[y(1)-0.2;y(2)-0.3];
    isterminal=zeros(2,1);
    direction=ones(2,1);
    end

This event function requires that the system is at least two-dimensional and defines two events, namely and . The integration will not be terminated if an event is detected and all zeros will be detected regardless of the direction of (increasing or decreasing).

We now consider the system `a`daptx in the directory `T`estruns/TestSystems of MATCONT with three state variables and two parameters. By runnning the script `t`estPoincare:

    TSTP=@testEV;
    OPTIONS = odeset('RelTol',1e-8,'Events',TSTP);
    hls = adaptx;
    [t,y,TE,YE,IE] = ode45(hls{2},[0 300],[0.3 0.5 -0.1],OPTIONS,1,0.8);
    x0 = y(end,:);
    [t,y,TE,YE,IE] = ode45(hls{2},[0 10],x0,OPTIONS,1,0.8);

we integrate the system `a`daptx from to and then further from to starting from the point with parameter values and we detect the points in the second run where or The output is given by

    TE =

        5.6334
        6.6979

    YE =

       -0.2247    0.3000    0.3131
        0.2000    0.4213   -0.1059

    IE =

         2
         1

The test is run by typing `t`estPoincare in the command line.