フィルターのクリア

How can I model conditionally defined exponential functions?

2 ビュー (過去 30 日間)
Thomas Veith
Thomas Veith 2018 年 11 月 30 日
コメント済み: Image Analyst 2018 年 11 月 30 日
I am using the MatLab Curve Fitting Toolbox to model a conditionally defined exponential function. My function is that y = exp(g) from 0 to 3, exp(p) from 3 to 4, and exp(g) from 4 to 7 (and I import g and p in an Excel spreadsheet). So it looks like the following:
function y=f(g,p)
t=(0:1:7)';
y1=exp(g).*(0<=t & t<=3);
y2=exp(p).*(3<t & t<=4);
y3=exp(g).*(4<t & t<=7);
y=y1+y2+y3;
end
And I build the model as follows:
v = fit(t,f(g,p),'exp2');
But that gives me a fitted curve that doesn't take account of the fact that that exp(g) is 'turned off' from 3 to 4, and so I get a big outlier as in the attached image. Any advice?
hyp1modelfailfailfail.jpg

採用された回答

TADA
TADA 2018 年 11 月 30 日
First of all, it's hard to get a good fit out of so little data points.
Second, your data in the code example is not a simple exponential function,
y = exp(g)*t
I think t is not a constant parameter, is it?
Moreover, I could be mistaken, but in the curve it looks like g and p are constants, because it's so straight, which means this is actually a linear function.
More importantly, the exponential fit works for a sum of exponentials, not a piecewise function of exponentials.
fit exponential model is that:
and not this:
for the later, I think you will have to map the discontinuities first (assuming you don't know their locations in advance) then fit seprately for each range
(Or if anyone knows how to do it with fit I will love to know too)
I know some people use fft or haar to find discontinuities, but if you know this is a decaying exponent, i think the simplest way is to use diff. the locations where the difference is positive, are the discontinuities. If this is an actual signal measured by some instrument and you have noise, you'll have to evaluate the noise and set some threshold to distinguish noise from discontinuities.
  1 件のコメント
Image Analyst
Image Analyst 2018 年 11 月 30 日
If he could attach the workbook with p and g, it would help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by