custom logarithmic fit with three coefficients
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Torsten
2023-3-6
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!