% plot invasion profile

set(0,                           ...
   'defaultaxesfontsize', 20,   ...
   'defaultaxeslinewidth', 1.2, ...
   'defaultlinelinewidth', 2.0, ...
   'defaultpatchlinewidth', 0.7); 
x = [-5.001:.01:5];
btcase=[0 , -2 2];
bet = -2; %this is the drift velocity
%bet = 0;
for j = 1:3
    bet=btcase(j);
bsq = sqrt(bet^2+4);

kp = (bsq+bet)/2
km = (bsq-bet)/2

f = (x>=0).*(exp(-km*x))/(km*bsq)...
    + (x<0).*(1/(km*bsq) + (1-exp(kp*x))/(kp*bsq));
sum(f)*0.01
%f = (1+sign(-x))/2+sign(x).*exp(-abs(x))/2;
figure(1)
if (j==1)
plot(x,f,'--', 'linewidth',2)
else
    plot(x,f, 'linewidth',2)

end

xlabel('\alpha x','fontsize',20)
ylabel('u_{n+1}/A_0','fontsize',20)
 text(-1.4,0.2,'\beta=-2','fontsize',20)
  text(1.2,0.6,'\beta=2','fontsize',20)
   text(1.25,0.2,'\beta=0','fontsize',20)
hold on 
set(gca,'Xtick',-5:2.5:5)

g = exp(-(bsq*abs(x)-bet*x)/2)/bsq;
figure(2)
if(j==1)
plot(x,g,'--', 'linewidth',2)
else
    plot(x,g, 'linewidth',2)
end
xlabel('\alpha x','fontsize',20)
ylabel('K(x)/\alpha','fontsize',20)
 set(gca,'Xtick',-5:2.5:5)
 hold on
 
 text(-3.4,0.15,'\beta=-2','fontsize',20)
  text(2.7,0.15,'\beta=2','fontsize',20)
   text(0.5,0.4,'\beta=0','fontsize',20)
end

