Pedrotti 11-11
Pedrotti 11-12
Pedrotti 11-13
Pedrotti 11-14
Pedrotti 11-15

What does this OCTAVE/MATLAB code do?

lambda=6.33e-5;
a=1e-3;
D=100;
k=2*pi/lambda;
xs=-20:0.1:20;
ii=1;
for x=xs
  E=0;
  for y=-a/2:lambda/2:a/2
   d=sqrt(D^2+(x-y)^2);
   E=E+e^(i*k*d);
  end
  I(ii)=abs(E)^2;
  ii=ii+1;
end
plot(xs,I)

Add comments where appropriate. Modify it to be able to work for arbitrary inputs.