function dNM = modelInvader(t,NM,del0,del1,b,lam,eps,mu,sigman,sigmam)
%derivatives of model with N=1 and with invading population 

%Input:
%NM = concatinated vector of two populations [N;M]
%sigman,sigmam: sigma of population N,M

n0 = max(NM(1),0); n1 = max(NM(2),0); 
m0 = max(NM(3),0); m1 = max(NM(4),0);

fn0 = b - del0*(n0+m0) - lam*sigman - mu;
fm0 = b - del0*(n0+m0) - lam*sigmam - mu;
fn1 = b - del1*(n1+m1) - lam*sigman - mu;
fm1 = b - del1*(n1+m1) - lam*sigmam - mu;

Dn0 = eps*sigman*n0*(n1*sigman + m1*sigmam);
Dm0 = eps*sigmam*m0*(n1*sigman + m1*sigmam);
Dn1 = eps*sigman*n1*(n0*sigman + m0*sigmam);
Dm1 = eps*sigmam*m1*(n0*sigman + m0*sigmam);

Ln = max(0,Dn0*(fn1-fn0)) - max(0,Dn1*(fn0-fn1));
Lm = max(0,Dm0*(fm1-fm0)) - max(0,Dm1*(fm0-fm1));

dn0 = fn0*n0 + max(0,(fn1 + mu)*n1) - Ln;
dm0 = -mu*n1 + Ln; 
dn1 = fm0*m0 + max(0,(fm1 + mu)*m1) - Lm;
dm1 = -mu*m1 + Lm;


dNM = [dn0;dm0;dn1;dm1];