Effacer les filtres
Effacer les filtres

Integrating Bessel Function Including for Each Value of Array-Valued Vector

2 vues (au cours des 30 derniers jours)
I'd like to integrate a function which has bessel functions in it for each value of Q.
I've seen that I should use quadv but this will get me a vector of the same length of Q ?
Q = 0:.1:1; z = 0:0.1:20;
h = sin(2*pi*z);
for i = 1:length(Q)
integ = @(z) besseli(0,z).*h.* (Q(i)) ...
./ (h.*(2*besseli(1,z) - h.*besseli(0,z)));
dP(i) = quad(integ,0,1);
end
Thanks.

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Sep 2017
You are using z for two different purposes. In the first line you make z a vector of specific values. In the second line you make h a vector that depends upon those z values. But then in your integ anonymous function, z has become whatever is passed by quad(), which will generally be a vector of variable length. You then try to multiply besseli(0,that vector) by h where h is the vector made up of specific values from the z that had existence outside the function.
Perhaps you need
Q = 0:.1:1; z = 0:0.1:20;
h = @(z) sin(2*pi*z);
for i = 1:length(Q)
integ = @(z) besseli(0,z).*h(z).* (Q(i)) ...
./ (h(z).*(2*besseli(1,z) - h(z).*besseli(0,z)));
dP(i) = quad(integ,0,1);
end
This will give you warning messages about minimum step size reached and possible singularity -- probably due to the singularity that the function has at approximately 0.43
  1 commentaire
Ezz El-din Abdullah
Ezz El-din Abdullah le 21 Sep 2017
Modifié(e) : Ezz El-din Abdullah le 21 Sep 2017
Thanks. Now, I deleted the vector z and it works fine.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Bessel functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by