% Schematic13.m %
clear; clf;
figure1=figure(1);
x0=0; x=linspace(-20,30,1001); c=0.2;

t=0;  u1=0.5*c*(sech(0.5*sqrt(c)*(x-c*t+x0))).^2;
t=15; u2=0.5*c*(sech(0.5*sqrt(c)*(x-c*t+x0))).^2;
t=30; u3=0.5*c*(sech(0.5*sqrt(c)*(x-c*t+x0))).^2;

plot(x(1:601),u1(1:601),'k-.','linewidth',1.0); hold on
plot(x(1:601),u2(1:601),'k--','linewidth',1.0);
plot(x(1:601),u3(1:601),'k-','linewidth',1.0);
plot(x(361),u2(361),'ko','linewidth',1.0,'MarkerSize',7);
plot(x(441),u2(441),'ko','linewidth',1.0,'MarkerSize',7);
plot(x(521),u2(521),'ko','linewidth',1.0,'MarkerSize',7);
AA=[x(361)^2 x(361) 1; x(441)^2 x(441) 1; x(521)^2 x(521) 1];
BB=[u2(361); u2(441); u2(521)];
CC=AA\BB;
PPP=(-CC(2)-sqrt(CC(2)^2-4.0*CC(1)*(CC(3)-u1(441))))/(2.0*CC(1));

plot([x(441) PPP],[u1(441) u1(441)],'k-','linewidth',1.0);
annotation(figure1,'arrow',[0.6915 0.6915],[0.639 0.329],'linewidth',1.0);
plot(x(441),u1(441),'ko','linewidth',1.0,'MarkerFaceColor',[0 0 0],'MarkerSize',7);
plot(PPP,u1(441),'ko','linewidth',1.0,'MarkerFaceColor',[0 0 0],'MarkerSize',7);
plot([x(441)+x(521)-PPP x(441)+x(521)-PPP],[0 u3(521)],'k-','linewidth',1.0);
annotation(figure1,'arrow',[0.615 0.685]+0.031,[0.639 0.639]+0.0665,'linewidth',1.0);
plot(x(441)+x(521)-PPP,u3(521),'k*','linewidth',1.0,'MarkerSize',9);
plot(x(521),u3(521),'k*','linewidth',1.0,'MarkerSize',9);
plot([x(361) x(361)],[-0.025 0.125],'k:','linewidth',1.0);
plot([x(441) x(441)],[-0.025 0.125],'k:','linewidth',1.0);
plot([x(521) x(521)],[-0.025 0.125],'k:','linewidth',1.0);
plot([x(521) x(521)],[0 0.125],'k-','linewidth',2.0);
plot([x(601) x(601)],[-0.025 0.125],'k:','linewidth',1.0);
plot([-15 12.5],[0 0],'k-','linewidth',2.0);

legend('$\eta^{n-1}$','$\eta^{n}$','$\eta^{n+1}$',2)
set(legend,'interpreter','latex','FontSize',18)
text('Interpreter','latex','String','$$x_{N_x-1}$$','Position',[-3.4 -0.01],'FontSize',20)
text('Interpreter','latex','String','$$x_{N_x}$$','Position',[0.6 -0.01],'FontSize',20)
text('Interpreter','latex','String','$$x_{N_x+1}$$','Position',[5.5 -0.01],'FontSize',20)
text('Interpreter','latex','String','$$p$$','Position',[4.6 -0.006],'FontSize',18)
text('Interpreter','latex','String','$$q$$','Position',[2.7 -0.006],'FontSize',18)
text('Interpreter','latex','String','$$q=x_{N_x}+x_{N_x+1}-p$$','Position',[-14.5 0.07],'FontSize',18)
set(gca,'XTick',zeros(1,0));
set(gca,'YTick',zeros(1,0));
axis([-15 12.5 -0.025 0.125])
daspect([100 1 1])
set(gcf,'PaperPositionMode','auto')