I am using the fitnlm function, but for some data I am receiving this error - Error using nlinfit>checkFunVals The function you provided as the MODELFUN input has returned Inf

1 次查看(过去 30 天)
Hi,
I am using fitnlm function to find a non-linea fit for sets of data. This is the function handle: F = @(b,mu)((mu.^(2*b(2)-1)).*exp(4*b(1)*(log(mu)).^2 + b(3)));
mu is an array ranging from 0.3 - 0.9, and the value of b changes per iteration (the function is within a loop) with the range of b(1): 0.01 - 0.03, b(2) = 0 - 1, b3 = 0 -100. The function works for some iterations but not for others. If you plug the values into the function manually, it is all fine.
The error I am recieving is "Error using nlinfit>checkFunVals The function you provided as the MODELFUN input has returned Inf" within "Error in nlinfit>LMfit (line 596)"
if funValCheck && ~isfinite(sse), checkFunVals(r); end
if you plug the values into the function manually, it is all fine. Warnings also appear for some iterations like:
"Warning: Some columns of the Jacobian are effectively zero at the solution, indicating that the model is insensitive to some of its parameters. That may be because those parameters are not present in the model, or otherwise do not affect the predicted values. It may also be due to numerical underflow in the model function, which can sometimes be avoided by choosing better initial parameter values, or by rescaling or recentering. Parameter estimates may be unreliable. " & "Warning: Rank deficient, rank = 0, tol = 0.000000e+00."
Please could someone help?
Thanks,
Josh
  4 个评论
Torsten
Torsten 2024-1-18
Try whether
F = @(b,mu) b(3)*mu.^b(2).*exp(b(1)*(log(mu)).^2)
instead of
F = @(b,mu)((mu.^(2*b(2)-1)).*exp(4*b(1)*(log(mu)).^2 + b(3)));
works better.
It's easy to deduce the parameters of the original equation once you can solve the modified one.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by