function [out1,out2,out3]=modeldelay1(t,x,flag,par)

d=par(1);
n=par(2);

y=zeros(2*n+2,1);
y(1)=x(2);
if n==0
    y(2)=-.2*x(2)-x(1);
else
y(2)=-.2*x(2*n+2)-x(1);
end
for i=2:(n+1)
    y(2*i-1)=0*n*(x(2*i-3)-x(2*i-1))/d; % righthand = 0 -- variable x(1) is not to be delay
    y(2*i)=1*n*(x(2*i-2)-x(2*i))/d; 
end

if nargin <3 | isempty(flag) 
out1=y;
else
    switch(flag)
        case 'init'
            out1  =  [];
            out2  =  [];
            out3  =  [];
        otherwise
            error(['Unknown flag''' flag ''.'])
    end
end