Complex values computed by fit.m function (Curve fitting Tool)

조회 수: 14 (최근 30일)
Matti Rademacher
Matti Rademacher 2019년 6월 26일
댓글: Matti Rademacher 2019년 6월 26일
Hi,
I am trying to use the fit.m function, but matlab throws the "complexValueComputed" exception, even though my x variable could not created complex values.
My x variable is: x = 1 - T./Tcrit and T is an array with max(Tsat) < Tcrit.
My y variable is an irrational function: y = a1 + a2 .*x.^(1/3) + a3 .* x.^(2/3)+ a4 .* x.^(3/3)+...
So there is just a possibilty to create complex values for Tsat > Tcrit, but this is not possible.
I even try to solve this problem by using the abs() function for my x variable, but nothing changed.
The error message is: "Complex value computed by model function, fitting cannot continue.Try using or tightening upper and lower bounds on coefficients."
and appears in fit.m in line 116 or for the iFit.m function in line 348.
Any help for resolving this problem would be greatly appreciated!
  댓글 수: 6
Stephen23
Stephen23 2019년 6월 26일
편집: Stephen23 2019년 6월 26일
Matti Rademacher
Matti Rademacher 2019년 6월 26일
I know that the eval-function is not the best solution, but the preworker of the scripts used it everywhere and it is not so easy to replace them all.

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

답변 (1개)

Torsten
Torsten 2019년 6월 26일
편집: Torsten 2019년 6월 26일
Since your fitting problem is linear in the coefficients a1,a2,a3,..., this is all you need to get the best fit parameters:
A = [ones(1368,1), Tsat.^(1/3), Tsat.^(2/3), Tsat.^(3/3), Tsat.^(4/3)];
b = psat;
sol = A\b;
a1 = sol(1)
a2 = sol(2)
a3 = sol(3)
a4 = sol(4)
a5 = sol(5)
Best wishes
Torsten.
  댓글 수: 7
Torsten
Torsten 2019년 6월 26일
So mag(1,1) is equal to 4 in your code ?
Matti Rademacher
Matti Rademacher 2019년 6월 26일
Yes, but anyway I think I found the problem's source: the fitoption normalize. This could be an explanation for complex values.

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by