exponential fit base 10
9 次查看(过去 30 天)
显示 更早的评论
hello, i want to fit a exponential function (base 10) to my data i tried use this code :
ft2 = fittype('a + b * 10^(-c*freq)','dependent',{'absol'},'independent',{'freq'},'coefficients',{'a','b','c'});
f2 = fit(freq,absol,ft2);
plot(f2,freq,absol);
but the fit I got was a const line. not a exponential one. any idea what my problem may be? thank.
0 个评论
采纳的回答
John D'Errico
2018-3-6
编辑:John D'Errico
2018-3-6
We don't see your data. Nor do we see the results of the fit. However the chances are very good that what you have are poor starting values. You have not provided any starting values. If you don't do so, then fit will use its own choice. With exponential functions in any form, arbitrary starting values are often a poor choice.
For example, suppose the starting value for c was 1. If the values in freq are at all large numbers, say on the order of 20 to 100, then we start out by raising 10^(-c*freq). But those numbers are all on the order of eps or far smaller. They are all essentially zero. Changing the value of c will not impact that. You still get effectively zero. Is this scenario likely? It sure as heck is likely. A variable named freq probably indicates something to do with frequencies. They won't necessarily be small numbers. They probably won't be negative, or zero.
There are other data related possibilities. One might be just crappy data, with really high noise, or possibly data corrupted by outliers. Without seeing your data, anything is just a wild guess on my part. But my best guess is just bad starting values.
In fact, there are some nice tricks to gain quite good starting values. (The one that really matters most is probably c, since if you have a good guess for c, then the others can be estimated quite well. But there are good ways to estimate c.) I can't help any more without your data though.
So if you want help (and won't show the data), then my advice is to provide something intelligent in the form of starting values. If you want better help, then my advice is to provide your data. (Best as a .mat file attachment to your question or to a comment.) Then I could show you clearly why fit got into trouble, as well as how you might make a better choice of starting values.
4 个评论
John D'Errico
2018-3-7
There are some nice tricks to estimate pretty good starting values for a model like this. But usually you would have a good idea what the rate constant might be, or at least a rough guess. And the rate constant is what really matters in any problem like this.
更多回答(1 个)
Jos (10584)
2018-3-6
Your plot command is incorrect, it seems (f2 is the fit result, not an x-value). So, try this:
plot(freq, f2(freq), 'r-')
3 个评论
Jos (10584)
2018-3-6
What is the output of fit?
I also think you might want to add a dot before the power symbol in the formula (matrix power vs element-wise power):
a + b * 10 .^ (-c * freq)
另请参阅
类别
在 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!