function [phi,phiprime]=resetting(b)
%   [PHI,PHIPRIME] = RESETTING(B) computes the resetting curve for the
%   Poincare oscillator. B is the strength of the stiulation, 
%   PHI is the initial phase ranging from 0 to 1 and PHIPRIME is the new
%   phase after resetting.

%   Copyright 2003
%   Centre for Nonlinear Dynamics in Physiology and Medicine

for i=1:51
phi(i)=.01*(i-1);
if i==51 phi(i)=.499999; end;
angle= 2*pi*phi(i);
rprime=sqrt(1+b^2+2*b*cos(angle));
argument=(cos(angle)+b)/rprime;
phiprime(i)=acos(argument)/(2*pi);
end;
for i=52:102
phi(i)=0.01*(i-2);
if i==52 phi(i)=.500001;end;
angle= 2*pi*phi(i);
rprime=sqrt(1+b^2+2*b*cos(angle));
argument=(cos(angle)+b)/rprime;
phiprime(i)=acos(argument)/(2*pi);
phiprime(i)=1-phiprime(i);
end;
