Integrating Bessel Function Including for Each Value of Array-Valued Vector
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ezz El-din Abdullah
am 21 Sep. 2017
Bearbeitet: Ezz El-din Abdullah
am 21 Sep. 2017
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.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Bessel functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!