필터 지우기
필터 지우기

Complex values with nlinfit

조회 수: 3 (최근 30일)
Kai Hillers
Kai Hillers 2020년 6월 3일
댓글: Kai Hillers 2020년 6월 3일
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
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
Kai Hillers
Kai Hillers 2020년 6월 3일
Thank you for your answer!
Can you elaborate why the values of m_wntr are too big for the modelfunction? How would i have to change the modelfunction if I'm not changing the data.

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

답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by