%
% MackeyGlass_dde23_demo.m
%
% MATLAB demo script for the vector field: MackeyGlass
%
% This file was generated by the program VFGEN (Version:2.1.0)
% Generated on  3-Jun-2007 at 12:24
%
%

function MackeyGlass_dde23_demo(stoptime)
    a = 0.2;
    b = 0.1;
    tau = 17.0;
    p_ = zeros(3,1);
    p_(1) = a;
    p_(2) = b;
    p_(3) = tau;

    x = zeros(1,1);
    x(1) = 0.5;

    lags = [tau];

    x0_ = [0.5];

    opts = ddeset('reltol',1e-8,'abstol',1e-11,'InitialY',x0_);
    sol = dde23(@(t_,y_,Z_) MackeyGlass_dde23(t_,y_,Z_,p_),lags,@(t_) MackeyGlass_history(t_,p_),[0 stoptime],opts);

    num_plot_samples = 500;
    tint = linspace(0,stoptime,num_plot_samples);
    xint = deval(sol,tint);
    clf
    plot(tint,xint,'linewidth',2);
    grid on
    xlabel('t');
    legend('x','Location','Best')
end

function x_ = MackeyGlass_history(t,p_)
    a          = p_(1);
    b          = p_(2);
    tau        = p_(3);
    x_(1) = 0.5+(0.02)*t;
end
