Effacer les filtres
Effacer les filtres

Evaluating a complicated integral in Matlab gives NaN

2 vues (au cours des 30 derniers jours)
MaxFrost
MaxFrost le 6 Fév 2020
Commenté : MaxFrost le 7 Fév 2020
I wish to plot the values of the following integral as a function of ψ.
where, and
Following is my code:
Nu = 4; % Group cardinality
Pt = 10^(-12); % Effective transmission power
fc = 3*10^9; % Carrier frequency
df = 10^4; % Sub-carrier spacing
c = 3*10^8; % Speed of light
dv = 0.01;
Vmax = 0:dv:100-dv; % Maximum velocity of UEs
b = pi*Vmax*fc/c/df;
f2 = zeros(1, length(b));
f0 = @(t) sin(t)/t; % Defining Si(z) function
for i = 1:length(b)
f1 = @(psi) integral(f0, 0, 2*b(i)*cos(psi), 'ArrayValued', true)./b(i)./cos(psi) - (sin(b(i)*cos(psi))).^2./b(i)^2./(cos(psi)).^2;
f2(i) = integral(f1, 0, pi/2, 'ArrayValued', true);
P_ICI = Nu*Pt - (2/pi)*Nu*Pt*f2;
end
I use the integral function of MATLAB to compute the integral but it gives me the following error.
Warning: Infinite or Not-a-Number value encountered.
In integralCalc/midpArea (line 397)
In integralCalc (line 65)
In integral (line 88)
In @(psi)integral(f0,0,2*b(i)*cos(psi),'ArrayValued',true)./b(i)./cos(psi)-(sin(b(i)*cos(psi))).^2./b(i)^2./(cos(psi)).^2
In integralCalc/iterateArrayValued (line 193)
In integralCalc/vadapt (line 130)
In integralCalc (line 75)
In integral (line 88)
In CA_1 (line 13)
Can anyone suggest a way to get around this? Or point out what is wrong? Many thanks!
  2 commentaires
darova
darova le 6 Fév 2020
Try small number instead of 0
MaxFrost
MaxFrost le 7 Fév 2020
Thanks! I got it.

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 6 Fév 2020
Modifié(e) : Matt J le 6 Fév 2020
Your integrand has a singularity at psi = pi/2. So perhaps try,
f2(i) = integral(f1, 0, pi/2*(1-eps), 'ArrayValued', true);

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by