#
Continuer example: a curve object

In this section a simple example is presented to illustrate the basic use of the continuer. This example generates a curve in the -plane such that . So if the user specifies a point reasonably close to this curve we get the unit circle. The defining function is

| (97)

In the following listing this curve is implemented. Do note that while there are no options needed, the curve file must return an option structure (see section 3.3).

curve.m
1 | `function out = curve`
2 | `%`
3 | `% Curve file of circle`
4 | `%`
5 | ``
6 | `out{1} = @curve_func;`
7 | `out{2} = @defaultprocessor;`
8 | `out{3} = @options;`
9 | `out{4} = []; %@jacobian;`
10 | `out{5} = []; %@hessians;`
11 | `out{6} = []; %@testf;`
12 | `out{7} = []; %@userf;`
13 | `out{8} = []; %@process;`
14 | `out{9} = []; %@singmat;`
15 | `out{10} = []; %@locate;`
16 | `out{11} = []; %@init;`
17 | `out{12} = []; %@done;`
18 | `out{13} = @adapt;`
19 | `function f = curve_func(arg)`
20 | `x = arg;`
21 | `f = x(1)^2+x(2)^2-1;`
22 | ``
23 | `function varargout = defaultprocessor(varargin)`
24 | `if nargin > 2`
25 | `s = varargin{3};`
26 | `varargout{3} = s;`
27 | `end`
28 | `% no special data`
29 | `varargout{2} = [];`
30 | `% all done succesfully`
31 | `varargout{1} = 0;`
32 | ``
33 | `function option = options`
34 | `option = contset;`
35 | ``
36 | `function [res,x,v] = adapt(x,v)`
37 | `res=[];`
38 | ``
curve.m

The file `curve.m` is stored in the directory `Testruns/TestSystems`. Starting computations at , the output in MATLAB looks like:

    >> init;
    >> [x,v,s]=cont(@curve,[1;0]);
    first point found
    tangent vector to first point found
    Closed curve detected at step 70

    elapsed time  = 0.1 secs
    npoints curve = 70

The generated curve is plotted in Figure 32 with the command:

    >> cpl(x,v,s)

In this case `x` has dimension 2, so a 2D-plot is drawn with the first component of `x` (value of the state variable ) on the x-axis and the second component of `x` (value of the state variable ) on the y-axis. The above commands are also executed by running `testdrawcurve`; the file `testdrawcurve.m` is in the directory `Testruns`.

Figure 32: Computed curve of `curve.m`