![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1110270/image.png)
How to calculate the peak-to-peak amplitude of a waveform?
57 views (last 30 days)
Show older comments
Hi All,
Sorry if I’m asking about the obvious, but could somebody please tell me how to calculate the peak-to-peak voltage of the following signal? I would like to know what the peak-to-peak amplitude of this signal is, and if I add random noise to it, how much the peak-to-peak amplitude will change. (fig file is attached)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1110240/image.png)
Many thanks in advance.
0 Comments
Accepted Answer
Star Strider
on 28 Aug 2022
Edited: Star Strider
on 28 Aug 2022
Fortunately, there are complete P-T complexes in thei record, making the calculations easier.
Detrending is important here in order to get uniform values. This requires a
degree polynomial to detrend it adequately, something that to me is a bit extreme, however I could not get any other detrending approach (highpass filtering for example_ to give a satisfactory result. As a general rule, the R-wave is measured from the previous P-R interval, since that is considdered to be an isoelectric reference. This measures the peak-to-peak amplitude between the R-deflection and the following S-deflection, since that is the greatest difference —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1110270/image.png)
LD = openfig(websave('Fig','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1110230/Fig.fig'));
Lines = findobj(LD, 'Type','line');
Xv = Lines.XData
Yv = Lines.YData
Fs = 1/(Xv(2)-Xv(1))
Yvf = detrend(Yv, 9);
Smin = islocalmin(Yvf, 'MinProminence',4000, 'MinSeparation',100);
Rmax = islocalmax(Yvf, 'MinProminence',5500);
Sdef = Yvf(Smin);
Rdef =Yvf(Rmax);
PtoP = Rdef - Sdef
figure
plot(Xv, Yvf, 'DisplayName','Filtered EKG')
hold on
plot(Xv(Rmax), PtoP,'r+', 'DisplayName','P-P Values')
% plot(Xv(Rmax), Yvf(Rmax),'r^', 'DisplayName','R-Deflections')
% plot(Xv(Smin), Yvf(Smin), 'rv', 'DisplayName','S-Deflections')
hold off
grid
legend('Location','best')
xlim([0 5])
Make appropriate changes to get different results.
.
16 Comments
More Answers (1)
Abderrahim. B
on 28 Aug 2022
Hi!
Use peak2peak function. Demo below:
load('ecgSignals.mat')
t = (1:length(ecgl))';
plot(t, ecgl)
peak2peak(ecgl)
% You may need to detrend the ecg signal before finding peak to peak
% amplitude.
dt_ecgl = detrend(ecgl);
plot(t, dt_ecgl)
peak2peak(dt_ecgl)
See Also
Categories
Find more on Signal Generation and Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!