NaN computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients.

36 views (last 30 days)
Hello,
I am using the Curve Fitting App to fit this model (from the Sheindorf–Rebuhn–Sheintuch "SRS"):
Q = k1*C1*(a11*C1+a12*C2)^(n1-1)
With these provided data:
% The x
C1 = [0 14.336 18.37041 35.612 48.91934 62.43846 84.19304 80.52791 98.55237 114.74732 121.88417];
% The y
C2 = [0 7.78606 18.16868 35.82219 40.7553 52.15498 58.57749 70.75204 81.02773 85.89886 94.22023];
% The z
Q = [0 35.44 44.81 47.172 55.1 59.22706 65.1487 69.83486 72.37768 75.673 85.26529];
After many attempts, I found that the fitting will not continue unless the (n1-1) >= 0, meaning n1 bounds should be from 1 to inf... which is incorrect in this case because n1 should be between 0 and 1.
Actually, this error is not logical, I mean why n1-1 must be positive? (Am I that bad in math?)
By the way, I tried this on two different versions of MATLAB (R2020a and R2022b).
Regards.
Here are some screenshots for the Fit Options:

Accepted Answer

ihssane houhou
ihssane houhou on 25 Jul 2023
It is about the first element 0 presented in each input vector: C1, C2, and Q.
Reasonable results are obtained after removing these zeros.
And the reason why it was hard to be detected is that whenever changing the values of the C1, C2, and Q and loading them using the Select Data icon, it is a must to empty the X data, Y data, and Z data boxes each time before adding the new C1 (the X data), C2(the Y data), Q(the Z data).

More Answers (1)

Torsten
Torsten on 24 Jul 2023
Edited: Torsten on 24 Jul 2023
a11 and a12 must be such that a11*C1 + a12*C2 > 0. Otherwise, the operation ^(n1-1) gives a complex result. The simplest example is (-1)^0.5 which gives the complex unit i.
And your model is overfitted. It can at most have three instead of four independent parameters:
Q = k1*C1*(a11*C1+a12*C2)^(n1-1) = k1*a11^(n1-1)*C1*(C1+a12/a11*C2)^(n1-1)
So K = k1*a11^(n1-1), A = a12/a11 and N = n1 are free parameters.
  5 Comments
Torsten
Torsten on 25 Jul 2023
Edited: Torsten on 25 Jul 2023
The Q = K* C1 *(C1+A*C2)^N is working fine of course, but the main purpos of this work is to find out the a11, a12, k1, and n1 values, which is not the case using this formula.
I thought that I have shown that it's not possible to fit a11 and a12 independently.
Say the solver tells you that it found a solution for Q = k1*C1*(a11*C1+a12*C2)^(n1-1).
Now choose a11' = const*a11, a12' = const*a12, n1' = n1 and k1' = 1/const^(n1-1) *k1 for an aribtrary constant "const".
a11', a12', n1' and n2' - although different from a11, a12, n1 and n2 - will give the same goodness of fit because they reproduce the same values for Q. That means that your model is ill-posed (it's called "overfitted").
It would be different if a11 and a12 were somehow related, e.g. a11^2 + a12^2 = 1 or something similar.
ihssane houhou
ihssane houhou on 25 Jul 2023
I found the cause of the error, it is regardless of how the formula is written, It is about the first element 0 presented in each input vector: C1, C2, and Q.
Reasonable results are obtained after removing these zeros.
And the reason why it was hard to be detected is that whenever changing the values of the C1, C2, and Q and loading them using the Select Data icon, it is a must to empty the X data, Y data, and Z data boxes each time before adding the new C1 (the X data), C2(the Y data), Q(the Z data).
Thank you for your time and effort sir.

Sign in to comment.

Categories

Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!