use findpeaks function for interpolation of signal peaks with damped sinusoidal oscillation
22 views (last 30 days)
Show older comments
Federico Paolucci
on 26 Jun 2022
Commented: Federico Paolucci
on 27 Jun 2022
hi all, i'm trying to calculate the damping coefficient of an object by interpolating the peaks of the acceleration signal. I was able, using findpeaks, to perform the interpolation. the problem is that I can't interpolate all the peaks, what can I do? another problem is that I have to consider only the peaks in the positive part of the signal. i am trying to use for and if loops but still not getting good results. thank you
This is the script that I am using:
load 'prova.txt' '-ascii' % file with acceleration data
t = prova(:,1);
a = prova(:,4);
dt=mean(diff(t));
t1=0.18;
t2=1.11;
id1= round(t1/dt);
id2= round(t2/dt);
t_tmp=t(id1:id2);
a_tmp=a(id1:id2);
[peak_value, peak_location] = findpeaks(a_tmp,"DoubleSided");
figure
plot(t_tmp,a_tmp)
hold on
plot(t_tmp(peak_location),a_tmp(peak_location),'ro')
From the script, I obtain:
to consider only the positive part of the signal, I proceeded like this
k=1;
for i=1:length(a_tmp)
if a_tmp(i)>0
a_tmp1(k)=a_tmp(i)
t_tmp1(k)=k;
k=k+1;
end
end
t_tmp1=t_tmp(1:length(a_tmp1),1)
figure
plot(t_tmp1,a_tmp1)
hold on
plot(t_tmp1(peak_location),a_tmp1(peak_location),'ro')
5 Comments
David Goodmanson
on 26 Jun 2022
Hi Federico,
could you post the arrays for a and t? (Since the arrays do not appear to be very large, a text file would work). And could you say a bit more about why you can only use the peaks in the positive parts of the signal?
Accepted Answer
Image Analyst
on 27 Jun 2022
As the others have said, it's way undersampled so the peaks are not really where the peaks should be -- they're in between. If I was forced to come up with a ballpark estimate for the exponential decay, I'd find the first peak, and the last peak, and just say that a perfect exponential decay went through them.
The general equation (with no y offset to raise or lower the curve) is
y = a1 * exp(-a2 * x)
and so you have two of those equations - one at each point.
y1 = a1 * exp(-a2*x1)
y2 = a1 * exp(-a2*x2)
The x and y are known. The two exponential parameters are unknown.
Just solve as you normally would using high school math. Divide the equations, etc.
log(y1/y2) = -a2*(x1 - x2)
and so on.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!