Info
This question is closed. Reopen it to edit or answer.
failure in initial user-supplied objective function evaluation
3 views (last 30 days)
Show older comments
c=3.8;
ncl=3;
nc=3;
syms u w n
Jn=besselj(n,u);
Jnp=diff(Jn,u);
Kn=besselk(n,w);
Knp=diff(Kn,w);
J0=Jnp/(u*Jn);
K0=Knp/(w*Kn);
CH=(J0+K0)*(J0+(ncl/nc)^2*K0)-n^2*(1/u^2+1/w^2)*(1/u^2+(ncl/nc)^2*1/w^2);
CHL=limit(CH,w,0); x0=(3);
for m=0:9
CHA=subs(CHL,n,m);
options = optimoptions('fsolve','Display','iter'); % Option to display output
fval= fsolve(matlabFunction(CHA),x0,options) % Call solver
0 Comments
Answers (1)
Walter Roberson
on 27 May 2015
Your CH has two 1/w^2 terms. As w approaches 0, those approaches infinity. You do not have any other use of w that might go to 0 "faster" to "cancel out" that infinity. Your CHL is therefore going to be infinity unless it happens to invoke some other behaviour like accidentally getting a 0/0 or a 0 * infinity.
You are not going to be able to get any further on your optimization until you change CH so it does not have 1/w, or until you change the limit so that you are not going to w=0. Remember, just because you take a limit() instead of directly evaluating a function doesn't mean that you won't get a division by 0. limit(1/w^2,w,0) is infinity no matter what you do.
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!