Damped cosine features in a exponential decay

2 Ansichten (letzte 30 Tage)
Kunjanni
Kunjanni am 4 Nov. 2020
Kommentiert: Star Strider am 5 Nov. 2020
Hi Guys,
I am trying to fit a decay curve which has some oscillatory feature in the decay. I tried to fit the data with the sum of a exponential with cosine function but didn't succed. Any help would be appreciated. I attached file here (column 1 is time and column 2 is the corresponding intensities).
Thanks and regards,
  2 Kommentare
Mathieu NOE
Mathieu NOE am 4 Nov. 2020
hello
I plotted your data
seems the data and the structure of the fit model will not match...
even by mentally removing the exponential trend, the remaining oscillations have variable amplitude and period as time goes... it will be tricky to find a combination of sinusoidal function that fits this portion of the signal
maybe a solution :
  1. remove the exp trend
  2. on the ramining signal, use zero crossing detection to compute cycle to cycle period (and therefore the instantaneaous frequency of a sinus signal)
  3. to fit that, compute a sine signal with the period / amplitude observed in step 2
Kunjanni
Kunjanni am 4 Nov. 2020
Thanks a lot for your comments and for valuable suggestions.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 5 Nov. 2020
This produces a reasonable approximation, however the signal appears to be changing its frequency toward the end:
D = load('Ampf.mat');
t = D.Ampf(:,1);
s = D.Ampf(:,2);
s = detrend(s,7);
yu = max(s);
yl = min(s);
yr = (yu-yl); % Range of ‘y’
yz = s-yu+(yr/2);
zt = t(yz(:) .* circshift(yz(:),[1 0]) <= 0); % Find zero-crossings
per = 2*mean(diff(zt)); % Estimate period
ym = mean(s); % Estimate offset
fit = @(b,x) b(1) .* exp(b(2).*x) .* (sin(2*pi*x./b(3) + 2*pi/b(4))) + b(5); % Objective Function to fit
fcn = @(b) norm(fit(b,t) - s); % Least-Squares cost function
B = fminsearch(fcn, [yr; -1; per; -1; ym]) % Minimise Least-Squares
xp = linspace(min(t),max(t));
yp = fit(B,xp);
figure
plot(t, s, '-p')
hold on
plot(xp, yp, '-r')
hold off
grid
It may be necessary to change ‘fit’ to something more closely approximating the process that produced your data. Retain the detrending step in the code.
  2 Kommentare
Kunjanni
Kunjanni am 5 Nov. 2020
Thanks a lot for your help :). It works for me.
Star Strider
Star Strider am 5 Nov. 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by