Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Sept. de 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

Más respuestas (0)

Categorías

Más información sobre Bessel functions en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by