# use findpeaks function for interpolation of signal peaks with damped sinusoidal oscillation

4 views (last 30 days)
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')
Federico Paolucci on 27 Jun 2022
yes i am using octave, but also matlab. Thanks for advice!
I know, you're right, the signal is quite inadequate. Unfortunately for the exam I am doing I am forced to use the linear accelerometer contained in the mobile app, with sampling frequency equal to 100 Hz. I am doing a dynamic calibration of the front wing of a Formula Student vehicle, I can only use a rubber hammer,to apply the pulses, which present this type of acceleration signal. I will repeat the experiment being careful to give the hammer perfectly vertically on the surface of the wing, making sure that the aileron is positioned on a perfectly horizontal plane.
Hi, this is t vector between 0.18 e 1.11 s (the display range I am using)
1.8453e-01
1.9126e-01
2.0060e-01
2.1040e-01
2.2023e-01
2.3051e-01
2.4127e-01
2.5099e-01
2.6031e-01
2.7032e-01
2.8113e-01
2.9161e-01
3.0119e-01
3.1045e-01
3.2029e-01
3.3594e-01
3.4220e-01
3.5079e-01
3.6029e-01
3.7083e-01
3.8122e-01
3.9192e-01
4.0056e-01
4.1062e-01
4.2065e-01
4.3080e-01
4.4257e-01
4.5067e-01
4.6544e-01
4.7110e-01
4.8044e-01
4.9271e-01
5.0045e-01
5.1060e-01
5.2049e-01
5.3042e-01
5.4048e-01
5.5039e-01
5.6053e-01
5.7041e-01
5.8062e-01
5.9062e-01
6.0282e-01
6.1099e-01
6.2020e-01
6.3036e-01
6.4050e-01
6.5047e-01
6.6037e-01
6.7024e-01
6.8030e-01
6.9016e-01
7.0020e-01
7.1596e-01
7.2029e-01
7.3073e-01
7.4024e-01
7.5044e-01
7.6149e-01
7.7041e-01
7.8016e-01
7.9033e-01
8.0041e-01
8.1108e-01
8.2048e-01
8.3028e-01
8.4073e-01
8.5123e-01
8.6159e-01
8.7058e-01
8.8029e-01
8.9047e-01
9.0034e-01
9.1166e-01
9.2023e-01
9.3038e-01
9.4050e-01
9.5045e-01
9.6016e-01
9.7053e-01
9.8271e-01
9.9023e-01
1.0007e+00
1.0104e+00
1.0203e+00
1.0309e+00
1.0406e+00
1.0503e+00
1.0603e+00
1.0705e+00
1.0847e+00
1.0908e+00
1.1006e+00
1.1102e+00
a vector
-1.8670e-01
-4.0000e-04
8.7700e-02
-5.0000e-04
1.3680e-01
-4.0000e-04
-1.6700e-01
1.4670e-01
9.4000e-03
-1.1800e-01
4.8500e-02
7.7900e-02
-1.6710e-01
1.9100e-02
8.7700e-02
-6.9100e-02
-5.9200e-02
1.5650e-01
-1.2790e-01
-1.0200e-02
6.8200e-02
-1.0400e-02
-1.2790e-01
1.6620e-01
-6.9000e-02
-2.9700e-02
4.8600e-02
4.8600e-02
-1.4740e-01
1.0750e-01
-1.9900e-02
-6.9000e-02
9.4000e-03
9.7600e-02
-1.3760e-01
5.8400e-02
4.5700e-02
-2.9800e-02
1.0740e-01
-7.8800e-02
-4.0000e-04
6.8200e-02
-2.0000e-02
-4.9400e-02
8.7800e-02
-2.0000e-02
-5.9200e-02
7.8000e-02
-3.0000e-04
-2.9800e-02
3.8800e-02
2.9000e-02
-7.8800e-02
2.9000e-02
2.9100e-02
-3.9600e-02
1.9100e-02
6.8100e-02
-7.8900e-02
2.8900e-02
3.2200e-02
-2.0100e-02
-3.9800e-02
7.7800e-02
-4.9600e-02
9.1000e-03
4.8300e-02
-6.0000e-04
-3.0100e-02
4.8300e-02
-3.0100e-02
2.8700e-02
2.2900e-02
-3.9900e-02
2.8700e-02
1.8900e-02
-5.9400e-02
3.6800e-02
2.8800e-02
I consider the positive peaks for the calculation of the damping coefficient

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.
Federico Paolucci on 27 Jun 2022
ok perfect, thanks for the advice. as I said maybe I will repeat the test, but I could also do so. As for the rest I understand, thanks!

R2022a

### Community Treasure Hunt

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

Start Hunting!