clear all
p.L=0.025;
p.C=0.025;
p.alpha=0.825;
p.beta=10;
p.r0=1.18;
p.n=3;
opts=odeset('RelTol',1e-6);
tskip=2000;
tend=50;

for i=5:6
  rng('default');
  xstart=zeros(3*p.n,1);
  if i==1; p.G=0.090/3; col='b-'; end
  if i==2; p.G=0.075/3; col='b-'; end
  if i==3; p.G=0.099/3; col='b-'; end % 0.092
  if i==4; p.G=0.050/3; col='r-'; end
  if i==5; p.G=0.099/3; col='r-'; end % 0.113
  if i==6; p.G=0.120/3; col='r-'; end  %0.114
  if i==7; p.G=0.000/3; col='m-'; end  %0.114

  for ii=0:p.n-1
    if i==1; xstart(3*ii+1:3*ii+3)=[6.374674155,3.16227766,1.169288347]'; end
    if i==2; xstart(3*ii+1:3*ii+3)=[6.374674155,3.16227766,1.169288347]'; end
    if i==3; xstart(3*ii+1:3*ii+3)=[6.374674155,3.16227766,1.169288347]'; end 
    if i==4; xstart(3*ii+1:3*ii+3)=[-4.442057487,-3.16227766,-0.01408704155]'; end 
    if i==5; xstart(3*ii+1:3*ii+3)=[-4.442057487,-3.16227766,-0.01408704155]'; end 
    if i==6; xstart(3*ii+1:3*ii+3)=[-4.442057487,-3.16227766,-0.01408704155]'; end 
    if i==7; xstart(3*ii+1:3*ii+3)=[-1.451976737,-3.16227766,-1.850734763]'; end 
  end
  xstart=xstart+0.000001*rand(3*p.n,1);
  [t,x] = ode45(@mlcnRHS,[0 tskip],xstart,opts,p);
  xstart=x(end,:);
  [t,x] = ode45(@mlcnRHS,[0 tend],xstart,opts,p);
  xplot=x; tplot=t;

  FileName="mlc118n3";
  if i==1; s="a"; end
  if i==2; s="b"; end
  if i==3; s="c"; end
  if i==4; s="d"; end
  if i==5; s="e"; end
  if i==6; s="f"; end
  if i==7; s="g"; end

  for ii=0:p.n-1
    clf
    plot(xplot(:,3*ii+2),xplot(:,3*mod(ii+1,p.n)+2),col)
    grid on;
    set(gcf,'PaperUnits','inch','PaperPosition',[0.25 0.25 4.5 2.5])
    text(12.0,-12.0,sprintf('y_%d',ii),'FontSize',18)
    text(-12.0,12.0,sprintf('y_%d',mod(ii+1,p.n)),'FontSize',18)
    set(gca,'XTickLabel',[]);
    set(gca,'YTickLabel',[]);
    axis([-15 15 -15 15])
    epsfilename=sprintf('%s%sy%dy%d.eps',FileName,s,ii,mod(ii+1,p.n));
    print('-depsc',epsfilename);
  end
  clf
  plot(xplot(:,3*0+1),xplot(:,3*0+2),col)
  grid on;
  set(gcf,'PaperUnits','inch','PaperPosition',[0.25 0.25 4.5 2.5])
  text(8.0,-12.0,sprintf('x_%d',0),'FontSize',18)
  text(-8.0,12.0,sprintf('y_%d',0),'FontSize',18)
  set(gca,'XTickLabel',[]);
  set(gca,'YTickLabel',[]);
  axis([-10 10 -15 15])
  epsfilename=sprintf('%s%sx0y0.eps',FileName,s);
  print('-depsc',epsfilename);
end
