## why I got zero answer?

Habib

### Habib (view profile)

님이 질문을 제출함. 18 Feb 2015
최근 활동 Habib

### Habib (view profile)

님이 댓글을 추가함. 19 Feb 2015
Hi everyone.
In below codes I used the trapz command for integration of u1_1, but answer is zero, what is wrong? And if I want to integrate respect to "r", what must I do?
clc
clear all
close all
a=3e-2;
z=0.42;
N=300;
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);
[x,y]=meshgrid(linspace(-a/2,a/2,N));
[teta,r] = cart2pol(x,y);
for i=1:N
for j=1:N
u1_1(i,j)=(r(i,j)./w).^2.*exp(-(r(i,j).^2)./w.^2);
end
end
for i=1:N
for j=1:N
u2(i,j)=trapz(u1_1(i,j));
end
end

로그인 to comment.

## 답변 수: 3

Erik S.

### Erik S. (view profile)

님의 답변 18 Feb 2015

Hi
You do the integration in the loop with only 1 value at the time, so the integral should be 0. You should pass vectors to the trapz function. Do you want to do a double integral? Or integrate each row in the matrix u1_1?

Habib

### Habib (view profile)

18 Feb 2015
thank you for your attention, Erik S.
so, I can't understand, but, this integration is one dimensional and I think "integrate each row in the matrix u1_1" be true. so what is your suggestion? what is solution ?

로그인 to comment.

Erik S.

### Erik S. (view profile)

님의 답변 18 Feb 2015

I send a file, try it.

Habib

### Habib (view profile)

18 Feb 2015
the answer of trapz,u2, is a 1*300 array and I want it be a 300*300 matrices and plot u2 by mesh.
like this:
do you think it is possible?

로그인 to comment.

Erik S.

### Erik S. (view profile)

님의 답변 19 Feb 2015

Hi again,
I'm not sure I understand your problem. But I send a new file, is it the result you need?

Habib

### Habib (view profile)

19 Feb 2015
Thanks.
Your codes give us a shape like the above figure but firstly we have to use Trapz and then plot it. The u1_1 = (r./w).^2.*exp(-r.^2./w.^2) equation is a laguerre-gaussian beam equation and I want to propagate it along 'L' distance. For propagation, I have to use in following integral.
I am so ashamed for bothered you. excuse me.
so how we can solve numerically this integral?

로그인 to comment.

Translated by