% Format: y = [P g q]'

function dydt = p2c_ssa(t,y,params) %#ok<INUSL>



g0   = params.g0;

l    = params.l;

T_R  = params.T_R;

tauL = params.tauL;

E_L  = params.E_L;

q0   = params.q0;

tauA = params.tauA;

E_A  = params.E_A;



P = y(1);

g = y(2);

q = y(3);



dPdt = 1/T_R*...

        (2*(g-l-q)*P+1e-8*g);

dgdt = -(g-g0)/tauL-g*P/E_L;

dqdt = -(q-q0)/tauA-q*P/E_A;



dydt = [dPdt; dgdt; dqdt];