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

for i=1:3
  rng('default');
  xstart=zeros(3*p.n,1);
  if i==1; p.G=0.20; tskip=1000; tend=50; end
  if i==2; p.G=0.24; tskip=600; tend=20; end
  if i==3; p.G=0.15; tskip=600; tend=20; end

  for ii=0:p.n-1
    xstart(3*ii+1:3*ii+3)=[-0.8,-0.3,-1.5]';
  end
  xstart=xstart+0.001*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="mlcn6";
  if i==1; s="a"; end
  if i==2; s="b"; end
  if i==3; s="c"; end

  for ii=0:p.n-1
    clf
    plot(xplot(:,3*ii+2),xplot(:,3*mod(ii+1,p.n)+2),'-b')
    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

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