exponential fit base 10

조회 수: 7 (최근 30일)
sarel aharoni
sarel aharoni 2018년 3월 6일
댓글: John D'Errico 2018년 3월 7일
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.

채택된 답변

John D'Errico
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
sarel aharoni
sarel aharoni 2018년 3월 7일
Thank alot!!! From some reason (maybe i did it worng) Startpoint not work for me...
But i use the fitoptions and after some tries got good fit
Thanks :)
John D'Errico
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)
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)
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)
sarel aharoni
sarel aharoni 2018년 3월 6일
Yet Not help
But thanks alot

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by