Info

This question is closed. Reopen it to edit or answer.

Why I get 'Warning: Infinite or Not-a-Number function value encountered.' using dblquad in this case?

2 views (last 30 days)
n = 1.42;
A = 980e-9; % lambda
wox = sqrt(log(2)/2)*(A/(pi*tan(2*pi/180)));% wox
woy = sqrt(log(2)/2)*(A/(pi*tan(10*pi/180)));% woy
k = 2*pi/A;
z = 5.8e-6; % La distancia
Rlx = 38.7e-6;
Rly = 3.7e-6;
Alpha = 78*pi/180;
RF = 0.2e-3;
syms x y x1 y1 real % A = lambda
exp_X1 = int(exp(- x1^2/wox^2 +(1i*pi*(x - x1)^2)/(A*z)), x1,-5*sqrt(2)*wox,+5*sqrt(2)*wox);
exp_Y1 = int(exp(- y1^2/woy^2 +(1i*pi*(y - y1)^2)/(A*z)), y1,-5*sqrt(2)*woy,+5*sqrt(2)*woy);
tlx_in = exp(-1i*(2*pi/A)*(n-1)*(Rlx-sqrt(Rlx^2-x^2)));
tly_out = exp(-1i*(2*pi/A)*(n-1)*(y*cos(Alpha/2)));
F = exp_X1.*exp_Y1.*tlx_in*tly_out;
F1 = matlabFunction((abs(F)).^2); % matlabFunction(Yn_xyz*conj(Yn_xyz));
text = func2str(F1);
new_text = strrep(text,'erf','erf_');
F1 = str2func(new_text);
sal = dblquad(F1,-Rlx,+Rlx,+Rly,+RF)
This code attempts to calculate the integral of F1 on the domain 'x': [-Rlx, Rlx] and 'y': [Rly, RF].
Testing shows that the error occurs on the domain in 'y'. For example, if I limit the integral in the y-axis as: [Rly, .25*RF] a numerical answer is obtained. If I put the [Rly, .3*RF] interval warnings arise again and NaN is obtained.
In my code I need to make this integral several times and it is not always as simple as limited to ".25*RF" in 'y' domain for an answer, plus I've noticed that the 0.25 value varies according to other parameters.
Thank you very much for the help!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!