필터 지우기
필터 지우기

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 CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by