Complex values with nlinfit
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Sulaymon Eshkabilov
2020년 6월 3일
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!