필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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.

채택된 답변

Walter Roberson
Walter Roberson 2017년 9월 21일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bessel functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by