%the right hand side for ode simulation:
function s_prime=deRHS(t,s)
global cm gca gl gk v2 v4 v1 v3 vk vca vl phi Iapp Inp BCL

V = s(1);
W = s(2);

Input = Inp/cosh(mod(t,BCL)-BCL/4);

minf = 0.5*(1.+tanh((V-v1)/v2));
 tmp = (V-v3)/v4;
      winf = 0.5*(1.+tanh(tmp));
      r = cosh(tmp/2);
      current = gca*minf.*(V-vca)+gk*W.*(V-vk)+gl*(V-vl) -Iapp;
      Fv = -current/cm;
      Fw = phi*r.*(winf-W);

s_prime = [Fv+Input Fw]';
