function dv_dt = simp_cell2(t,v) global Q global Ca global Ve global Vi global B global Rmax global Kp5 global tp global frac_on Ne = v(1); Ni = v(2); flow_in = Q.*Ca.*step(t,tp,frac_on); flow_out = Q.*Ne./Ve; trans_e_to_i = B.*Ne./Ve; trans_i_to_e = (Rmax.*Ni./Vi)./(Ni./Vi + Kp5); dv_dt = zeros(2,1); dv_dt(1) = flow_in - flow_out + trans_i_to_e - trans_e_to_i; dv_dt(2) = trans_e_to_i - trans_i_to_e; function out = step(t,tp,frac_on) t_cyc = rem(t,tp); if t_cyc < tp.*frac_on out = 1; else out = 0; end