custom logarithmic fit with three coefficients

4 次查看(过去 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.

采纳的回答

Torsten
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 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by