clear all
Nc=3;Np=80;dnmax=2E-4;
n0=1.45;
L=0.01;
lambda0=1.55E-6;
lambdamin=1.5497E-6;
lambdamax=1.5503E-6;
z0=L;rho0=[0, 0];
z=L:(-L/(Nc-1)):0;
dn=dnmax*(ones(1,Nc)-2*rand(1,Nc)); 
lambda=lambdamin:(lambdamax-lambdamin)/(Np-1):lambdamax;
rtarget=zeros(1,Np);
ref=[];

for i=1:Np
  delta0=2*n0*pi*(1/(lambda(i))-1/lambda0);
  if abs(lambda(i)-lambda0)<0.1E-9 
      rtarget(i)=1;
  end
  [zout,rhoout]=ode45(@(t,y) fctode(t,y,delta0,lambda0,dn,z),[L,0],rho0);
  R=rhoout(end,1)^2+rhoout(end,2)^2;
  ref=[ref,R];
end
error=(sum((abs(ref-rtarget)).^0.75))^(1/0.75);
disp('error:');disp(error)
clf
plot(lambda,ref,'black-')
hold on
plot(lambda,rtarget,'b-');
%
%