I have this sum with the Bessel function that I am trying to calculate and plot.
Any help would be greatly appreaciated.
Thank you

댓글 수: 2

Torsten
Torsten 2022년 8월 10일
편집: Torsten 2022년 8월 10일
Where is the error and what is the error message ?
By the way: It's nonsense to determine the roots again and again with every call of "findLr".
Determine them only once at the beginning of your program.
mery
mery 2022년 8월 10일
편집: mery 2022년 8월 10일
the error is
Error using ==> findLr
Too many input arguments.
Error in ==> findLp at 5
Lp(i)= findLr(rr1,K,n,sstep);
Error in ==> tset at 4
findLp(K,n,sstep)

댓글을 달려면 로그인하십시오.

 채택된 답변

Torsten
Torsten 2022년 8월 11일
편집: Torsten 2022년 8월 11일

3 개 추천

n = 60;
sstep = 1;
a_k = J0ROOTS(n,sstep);
r = (0:0.01:1).';
t = 0:0.1:1;
S = zeros(numel(r),numel(t));
for i = 1:numel(t)
S(:,i) = sum(2*besselj(0,a_k.*r)./(a_k.^2.*besselj(1,a_k)).*exp(-a_k.*t(i)),2);
end
plot(r,S)
function x=J0ROOTS(n,sstep)
if nargin==0
n=20;
sstep=1;
elseif nargin==1
sstep=1;
end
J0=@(x) besselj(0,x);
k=0; i=0;
while k<n
i1=i+sstep;
if J0(i)*J0(i1)<0
k=k+1;
x(k)=fzero(J0,[i i1]);
end
i=i1;
end
end

댓글 수: 6

mery
mery 2022년 8월 11일
@Torsten, Thank you very much.
in my problem, I have 0<=t<inf how can I add this condition?
Torsten
Torsten 2022년 8월 11일
in my problem, I have 0<=t<inf how can I add this condition?
Incorporated.
mery
mery 2022년 8월 11일
@Torsten This community is great because there are people like you.
Thank you, sir.
Andrew Omame
Andrew Omame 2023년 3월 30일
I am having issue running this code on my MATLAB R2014a version.
The error messgae I get is:
Error using .*
Matrix dimensions
must agree.
Please can anyone help on what to do to resolve this.
n = 60;
sstep = 1;
a_k = J0ROOTS(n,sstep);
r = (0:0.01:1).';
t = 0:0.1:1;
S = zeros(numel(r),numel(t));
for i = 1:numel(t)
for k = 1:numel(r)
for l = 1:n
S(k,i) = S(k,i) + 2*besselj(0,a_k(l)*r(k))/(a_k(l)^2*besselj(1,a_k(l)))*exp(-a_k(l)*t(i));
end
end
end
plot(r,S)
function x=J0ROOTS(n,sstep)
if nargin==0
n=20;
sstep=1;
elseif nargin==1
sstep=1;
end
J0=@(x) besselj(0,x);
k=0; i=0;
while k<n
i1=i+sstep;
if J0(i)*J0(i1)<0
k=k+1;
x(k)=fzero(J0,[i i1]);
end
i=i1;
end
end
Andrew
Andrew 2023년 4월 20일
This has now worked on my MATLAB R2014a version. Thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Bessel functions에 대해 자세히 알아보기

질문:

2022년 8월 10일

댓글:

2023년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by