
% Ploting a movie of the breather solution for the modifed Kdv (mKdV)

l=2;k=0.7;a=-5;b=-5;m=k*(k^2-3*l^2);n=l*(3*k^2-l^2);

ti=1;tf=5;
xi=0;xf=20;

x=xi:0.05:xf;
tspan=ti:0.1:tf;

figure(1)
clf

t=ti;
u0 = -2.*(l.*cos(k.*x+m.*t+a)./cosh(l.*x+n.*t+b)- ...
      l.^2./k.*sin(k.*x+m.*t+a)./cosh(l.*x+n.*t+b).^2.*sinh(l.*x+n.*t+b))./ ...
      (1+l.^2./k.^2.*sin(k.*x+m.*t+a).^2./cosh(l.*x+n.*t+b).^2);

mu=min(min(u0));
Mu=max(max(u0));
M=max(-mu,Mu);
pmin = -M -0.1*(M+M);
pmax = M +0.1*(M+M);

plot(x,u0,'LineWidth',2)
axis([xi xf pmin pmax]);
title('Breather solution for the mKdV')
xlabel('x');
ylabel('u(x,t)');

fprintf('Press any key to continue...')
pause

for t=tspan
 u = -2.*(l.*cos(k.*x+m.*t+a)./cosh(l.*x+n.*t+b)- ...
      l.^2./k.*sin(k.*x+m.*t+a)./cosh(l.*x+n.*t+b).^2.*sinh(l.*x+n.*t+b))./ ...
      (1+l.^2./k.^2.*sin(k.*x+m.*t+a).^2./cosh(l.*x+n.*t+b).^2);
 plot(x,u,'LineWidth',2)
 axis([xi xf pmin pmax]);
 title('Breather solution for the mKdV')
 xlabel('x');
 ylabel('u(x,t)');
 pause(0.1);
end

fprintf('\nPress any key to continue...')
pause

x=0:0.04:15;
t=0:0.01:6;
[X,T]=meshgrid(x,t);

set(gca,'FontSize',[16]);
figure(2)
clf

U = -2.*(l.*cos(k.*X+m.*T+a)./cosh(l.*X+n.*T+b)- ...
     l.^2./k.*sin(k.*X+m.*T+a)./cosh(l.*X+n.*T+b).^2.*sinh(l.*X+n.*T+b))./ ...
     (1+l.^2./k.^2.*sin(k.*X+m.*T+a).^2./cosh(l.*X+n.*T+b).^2);

surfl(X,T,U);
shading interp
colormap(gray)
ylabel('t')
xlabel('x')
zlabel('u(x,t)')
title('Breather solution for the mKdV')
view([15 52])

