NaN computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients.
Mostrar comentarios más antiguos
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:


Respuesta aceptada
Más respuestas (1)
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 comentarios
ihssane houhou
el 25 de Jul. de 2023
My formula is
%Q = K* C1 *(C1+A*C2)^N
with K, A and N being unknown. So you can only use three instead of four independent parameters.
And depending on the initial values for the parameters, it's not surprising if you get different results.
% 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];
fun = @(p)p(1)*C1.*(C1+p(2)*C2).^p(3);
F = @(p)fun(p)-Q;
p0 = [1 1 1];
format long
p = lsqnonlin(F,p0,[0 0 0],[Inf Inf Inf],optimset('MaxFunEvals',10000,'MaxIter',10000))
norm(F(p0))
norm(F(p))
ihssane houhou
el 25 de Jul. de 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
el 25 de Jul. de 2023
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!