필터 지우기
필터 지우기

Getting complex values for fitting parameters using nlinfit. Can anyone explain the reason why?

조회 수: 3 (최근 30일)
Hello everyone,
I am using the attached script to fit some data. All the input data for "nlinfit" are real numbers but the fitting is yielding complex variables even though the imaginary part of the complex number is 0.000i. Can anyone explain how to get real numbers from this script?
P.S. I've seen some of the answers suggesting to check if there's negative input values that might cause this problem. I'm fairly certain I do not have any negative input values.

채택된 답변

David Goodmanson
David Goodmanson 2018년 7월 30일
Hi Anik,
In the Ag case, the initial values are b0_ag=[5 1.5 1.5]
Take the first value of Stress_silver, Stress_silver = 1.5012771392081736
The initial value of z_ag is
z_ag = b0_ag(1).*(1-Stress_silver./b0_ag(3)).^b0_ag(2);
The expression (1 - ....) is negative and is being taken to the 1.5 power, so you get a complex answer. There are other cases as well. In the case of ni, as soon as b_ni(2) changes from its initial value b0_ni(2) = 2 to, say 2.01, the result is complex.
  댓글 수: 1
Anik Faisal
Anik Faisal 2018년 7월 30일
Thanks David! I get your point. I'll make sure the initial values are properly selected now. Appreciate it

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by