fzero returns complex result
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi,
I am running this code
f4=@(x) 0.1*0.4*(0.1*x+100)^(-0.8)-0.1*0.5*(-0.1*x+100)^(-0.8)+0.5*0.1*(0.5*x+100)^(-0.8);
fzero(f4,3)
and it only returns my NaN
Exiting fzero: aborting search for an interval containing a sign change because complex function value encountered during search. (Function value at -230.705 is -0.0043742-0.0033056i.) Check function or try again with a different starting value.
ans =
NaN
But if I change that the start poin to 200 I can get the result I want which is 225.3938. My question is how can I get the real root in general case? Before I get the solution I can't tell where is it so I can't choose a proper start point. I can't just randomly try different start points every time when I solve a function like this...
댓글 수: 0
답변 (1개)
Walter Roberson
2013년 3월 26일
Analyze the parts of your expression. You have
(-0.1*x+100)^(-0.8)
That is going to go complex if (-0.1*x+100) < 0, which is x > 1000. Likewise analyze the other subexpressions. You will be able to establish an upper and a lower bound on when the function goes complex. Then use the interval x0 form of fzero
fzero(f4, [-31415926, 2718285]) %for example
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!