Hi everybody. In second "for" nesting loop, I want to use Trapz command (numerical integration) for integration from an N*N matrix (u_2) but I got zero answer? What is wrong? I hope one give an answer.
clc
clear all
close all
aa=3e-2;
E0=10000;
z=0.42;
L=z;
N=100;
lambda=1030e-9;
k=2*pi/lambda;
w0=0.0001;
zr=pi*w0^2/lambda;
R=z*(1+(zr/z)^2);
w=w0*sqrt(1+(z/zr)^2);
D1=linspace(-aa/2,aa/2,N);
[x,y]=meshgrid(D1,D1);
b=(lambda*L)/(N*aa);
D2=linspace(-b/2,b/2,N);
[xx,yy]=meshgrid(D2,D2);
RR=1.5;
u1=ones(size(x));
u_2=u1;
u2=ones(size(xx));
[teta,r]=cart2pol(x,y);
[teta1,rr] = cart2pol(xx,yy);
for i=1:N
for j=1:N
u1(i,j)=E0*(r(i,j)/w)*exp(-(r(i,j)/w).^2);
end
end
for i=1:N
for j=1:N
u_2(i,j)=u1(i,j)*besselj(1,-k*r(i,j)*rr(i,j))*exp(-1i*k*rr(i,j)^2/(L*w^2))*cos(teta1(i,j));
u2(i,j)=trapz(u_2(i,j));
end
end