custom logarithmic fit with three coefficients
4 views (last 30 days)
Show older comments
Hello everyone,
I am trying to fit a custom logarithmic function
logfit2 = fittype('a + b*log(c*x)','dependent',{'y'},'independent',{'x'}, 'coefficients',{'a','b','c'});
fitulog2=fit(urot2,z,logfit2); plot(fitulog2,'magenta');
and the data are urot2 = [5.1689; 6.2631; 7.1724; 8.1874]; and z=[20;40;60;80]; I get the error:
Error using fit>iFit
Complex value computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.
Did anyone use the above function for fitting? How do I set lower and upper bounds on coefficients?
Thanks, Petr.
0 Comments
Accepted Answer
Torsten
on 6 Mar 2023
It doesn't make sense to use three fitting parameters for the function type you supply.
a + b*log(c*x) = a + b*log(c) + b*log(x)
So the fittype should be
u + v*log(x)
This way, you also circumvent the problem of a negative value for c which makes log(c*x) complex-valued (the reason for your error message).
0 Comments
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!