how to use fsolve with interval
Afficher commentaires plus anciens
Hi guys,
i got a problem with using fsolve, i want to define an interval for my problem but i can't.
This is my code
a = 20;
m = 12;
J = [0.01 0.02 0.05 0.1 0.2 0.5 1 2 5 10 20 50];
for j = 1:m
for i = 1:a
fnA=@(x) x*besselj(1,x)/besselj(0,x)-J(j);
A(i,j)=fsolve(fnA, i);
end
end
This code gives me roots of equation but it repeats roots sometimes. so i tried to replace this
A(i,j)=fsolve(fnA, i);
with
A(i,j)=fsolve(fnA, [start end]);
but i got error.
How can i solve it.
Thanks.
Réponses (1)
Walter Roberson
le 14 Avr 2019
0 votes
fsolve() does not permit intervals to be specified.
fzero() permits specifying intervals. fzero() is restricted to single equations in one variable, which it appears might be good enough for your purpose.
5 commentaires
ekrem yilmaz
le 14 Avr 2019
Walter Roberson
le 14 Avr 2019
I am not sure what you expect. The roots are a varying distance apart, mostly slightly more than 3 apart. You are asking to solve at locations increasing by 1 each time. The "closest" root is going to stay the same for 2 to 3 numbers in a row (depending on exactly how the rounding works out.)
What is the task? Do you need to find a certain fixed number of roots? The "first" so-many roots? If so, then at any one point if the root you just found is within 1 of the previous root, then try the next integer. Once you have found two roots, then take the difference between them as and add that to the higher root to get the starting point for the next search.
It appears to me that as x increases, the distance between roots approaches pi.
ekrem yilmaz
le 15 Avr 2019
Walter Roberson
le 15 Avr 2019
At the moment I do not see any connection between the A you solve for and the A you give the equation for.
Bi is given a subscript of i but not of n, which implies that as used in the equation for A that it should be independent of the n that is the variable of summation. But that seems weird. I suspect that B should be subscripted with n rather than i.
With Bi being Xn*J1/j0 and with it being used squared in A, that would be Xn^2*(J1/J0)^2 . But that is being used divided into Xn^2 in A, so that term would seem to calculate down to the simplier (J0/J1)^2.
I do not see any connection to eigenvalues.
ekrem yilmaz
le 17 Avr 2019
Catégories
En savoir plus sur Numeric Solvers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
