Hello,
Below is a transcendental equation that I would like to solve:
z*besselj(1,z) - c*besselj(0,z) = 0
where c is a constant and z is the variable to be determined. I know that I need to solve this using fzero(fun,x0) and I would like to use the initial value x0=1. However, I am struggling with "fun", i.e., I'm not sure how to make the above equation into the right format to use in fzero. Ultimately, I would like to make a list of solutions of z for each value of c from 0 to 225 with a step size of 0.01.
Anything helps!
Thanks,
John

 채택된 답변

Star Strider
Star Strider 2014년 4월 28일

0 개 추천

I suggest:
f = @(z,c) z.*besselj(1,z) - c.*besselj(0,z);
then call fzero with a vector of c values:
c = ...
for k1 = 1:length(c)
ci = c(k1);
z = fzero(@(z) f(z,ci), 1);
end
There are going to be an infinity of zeros for every value of c, so obviously more than one solution.

댓글 수: 6

Hi,
Thanks for your help. I have tried this:
f = @(z,c) z.*besselj(1,z) - c.*besselj(0,z);
c = 0:0.01:225;
for k1 = 1:length(c)
ci = c(k1);
z = fzero(@(z) f(z,ci), 1);
end
and I get only one solution for z, which is the solution closest to x0=1 for c=225. However, I would like a list of solutions for z (near x0=1) for all of the c values defined by the vector I used above. (I understand I'll only get the first solution to the equation closest to x0=1 for each value of c). I am new to the "for" statements. Could you please point me in the right direction?
Thanks,
John
My error, sorry. I posted an earlier version without the subscript for z.
Change:
z = fzero(@(z) f(z,ci), 1);
to:
z(k1) = fzero(@(z) f(z,ci), 1);
and you should have all of them.
John Moseley
John Moseley 2014년 4월 29일
Ah, I see. This works perfectly. Thanks again.
John
Star Strider
Star Strider 2014년 4월 29일
My pleasure!
(The sincerest form of appreciation on MATLAB Answers is to accept the one that solves your problem. This helps others who may be looking for a solution to the same problem.)
John Moseley
John Moseley 2014년 4월 29일
I just remembered to do that. Sorry about that.
John
Star Strider
Star Strider 2014년 4월 29일
편집: Star Strider 2014년 4월 29일
Thanks!
I also should have made sure I’d added the subscript to z in my first post.

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

추가 답변 (0개)

카테고리

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

질문:

2014년 4월 28일

편집:

2014년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by