% RuKu integrator for FitzHugh system with parameters

function r=ex5fitzhughfct(dq,x)

global dT
dt=.02; % local integration step
nn=fix(dT/dt);

p=x(1:dq,:);
xnl=x(dq+1:size(x(:,1)),:);
for n=1:nn
k1=dt*fc(xnl,p);
k2=dt*fc(xnl+k1/2,p);
k3=dt*fc(xnl+k2/2,p);
k4=dt*fc(xnl+k3,p);
xnl=xnl+k1/6+k2/3+k3/3+k4/6;
end
r=[x(1:dq,:); xnl];

function r=fc(x,p);
a=.7; b=.8; c=3.;
r=[c*(x(2,:)+x(1,:)-x(1,:).^3/3+p); -(x(1,:)-a+b*x(2,:))/c];




