Fit 2 exponential to a curve
조회 수: 14 (최근 30일)
이전 댓글 표시
Hi,
I am working on fitting algorithm to fit a double exponential to a given curve. These exponentails are RC time constants for two different combinations of R and C, so for R1*C1 the time constant is T1 and for R2*C2 the time constant is T2. Starting from point A in my top image below, the curve follows T1 till Point B, and from Point C (Point C would be much closer to Point B, but for clarity I have shown it to be further away from Point B) till Point D (or even further, but the curve is flat so it doesn't matter) the curve follows T2. The curve is obtained by experiment and I would like to find out Point B, Point C, T1 and T2. I have tried multiple fitting algorithms, nothing works, except for the one where I assume Point B and Point C coinside. The equation that works:
ft = fittype('S + A*((h*(1-exp((T-x)/T1))) + (1-h)*(1-exp((T-x)/T2)))','problem',{'S','A','T'});
fo = fit(x,y,ft,'problem',{Sx,Ax,Tx},'StartPoint',[1,10^-2,10^-2],'Lower',[0,10^-6,10^-6],'Upper',[1,10^-2,10^-2]);
Where:
Sx = Starting Amplitude [Known]
Ax = Final Amplitude [Known]
Tx = Starting Time [Known]
x = Data to fit [Independent Variable]
y = Data to fit [Dependent Variable]
h = coefficient 1 [ Min = 0, Max = 1] = Fraction of amplitude (Ax) that follows time constant T1 [where Point B and Point C are together]
T1 = coefficient 2 [ Min = 10^-6, Max = 10^-2] = Time constant for first combination of RC i.e. R1*C1
T2 = coefficient 3 [ Min = 10^-6, Max = 10^-2] = Time constant for second combination of RC i.e. R2*C2
Original Curve:
Zoomed in image of the fittied Curve, Red curve is Original Signal and Blue curve is the fitted curve. The dashed horizontal line in below image is the value of 'h' in above fitting algorithm that provides the seperation point between the RC time constants.
In the zoomed in image, it is clear that that fitted curve is slightly overestimating the first RC time constant T1 and underestimating the second RC time constant T2. In this particular example of the recorded data, shown above, the fitting algorithm works good and gives me expected values. But, in another example, shown below (again Red curve is original signal, Blue curve is fitted curve and dashed horizontal line is the value of 'h'), the fitting algorithm gives inaccurate results.
If there was a way I could seperate Point B and Point C (shown in first image) in the fitting algorithm, meaning T1 ends at Point B and T2 starts at Point C then I am quite sure I would get exact result in all recorded cases. Any help in this regard is highly aprriciated, thanks in advance!
댓글 수: 12
답변 (1개)
Image Analyst
2020년 4월 22일
Are you sure you're picking the right model? Maybe it's the "rate equation" instead of an exponential decay. I attach demos for each type of equation.
댓글 수: 2
Image Analyst
2020년 4월 23일
If you need me to do it, then attach your x and y in a .mat file with the paper clip icon.
save('answers.mat', 'x', 'y');
참고 항목
카테고리
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!