MATLAB: How to find Peak to Peak delay

arrhythmiabiomedical signal processingecgpeak distancepeak to peak delayphysionetr to r delay

How to find peak to peak delay of below shown ECG signals?
The code to plot above ECG signal is
load 16786m; figure(); plot(val(1,:));
I also want to find peak to peak delay of another ECG signal shown below:
The code to plot above signal is
load 100m; figure(); plot(val(1,:));
Source Codes are available here to download.
Will the same code detect peak distances for both ECGs?

Best Answer

Using my own code:
D = load('16786m.mat'); % Read EKG File
EKG = D.val/200; % Gain From the ‘info’ File
Fs = 128; % Fs From the ‘info’ File
tv = linspace(0,size(EKG,2),size(EKG,2))/Fs; % Time Vector
[pks,t] = findpeaks(EKG(1,:), Fs, 'MinPeakHeight',1); % See ‘findpeaks’ Documentation
RR = diff(t); % RR Intervals (sec)
BBRate = 1./RR; % Beat-To-Beat Rate (Beats/sec)
Rate = mean(BBRate); % Mean Rate (Beats/sec)
figure(1)
plot(tv,EKG(1,:)) % Plot EKG
hold on
plot(t, pks, '+r') % Plot R Peaks
hold off
grid
xlabel('Time (s)')
ylabel('Amplitude (mV)')
legend('EKG', 'R', 'Location','SE')
Related Question