MATLAB: Exponential fit base 10

curve fittingexponential

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.

Best Answer

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.