Getting complex values for fitting parameters using nlinfit. Can anyone explain the reason why?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Anik Faisal
le 30 Juil 2018
Commenté : Anik Faisal
le 30 Juil 2018
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.
0 commentaires
Réponse acceptée
David Goodmanson
le 30 Juil 2018
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!