Complex values with nlinfit
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone,
my code looks like this:
%initializing values
u_star = .2;
kappa = .4;
z_0 = 10^-6;
d = 0;
alpha = .11;
z = [33 40 50 60 70 80 90];
%sector means
m_smmr = [6.5261 6.6065 6.9178 6.9645 7.1122 7.3116 7.4411];
m_wntr = [10.5684 10.7004 11.2594 11.4037 11.6157 11.9577 12.1230];
%modelfunction
wpfun = @(a,z) (a(1) / kappa)*log((z-d)/a(2));
a = [u_star z_0];
wpsmmrfit = nlinfit(z,m_smmr,wpfun,a);
wpwntrfit = nlinfit(z,m_wntr,wpfun,a);
I expect real values for both fits, but the wpwntrfit is giving me a complex output. My outputs look like this:
wpsmmrfit =
0.3645 0.0269
wpwntrfit =
0.6349 - 0.0000i 0.0441 - 0.0000i
I have no idea why or whats going on. How do I make the wpwntrfit have non complex outputs?
Kind regards,
Kai
2 Commenti
Sulaymon Eshkabilov
il 3 Giu 2020
If your chosen model logarithmic function is correct or what you need to use, then the data (Y) m_wntr need to be adjusted. By changing the values of m_wntr your fit model coefficients will be real. E.g.:
wpwntrfit = nlinfit(z,m_wntr-5,wpfun,a)
0.6349 1.0295
Or you'd need to change the model function type: wpfun
Risposte (0)
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!