MATLAB: How to find Q and S point in QRS complex of ECG signal

ecgphysionetqrs complexsignal processingthresholding peaks in signal

How to find Q and R points of ECG signal shown below?
Code:
load 16265m.mat;
plot(val(1,:))

Best Answer

The first trace doesn’t have any S-waves, so don’t look for them. The EKG morphology is dependent on the lead placement and heart health. The second one is a very sick heart, with a left bundle-branch block pattern. It also has an RSR' pattern, so you have to be careful to not detect the first R-deflection.
My code:
q = load('Explorer 16265m');
EKG1 = q.val(1,:);
EKG2 = q.val(2,:);
Fs = 128;
t = [0:size(EKG1,2)-1]/Fs;
[R1,TR1] = findpeaks( EKG1, t, 'MinPeakHeight',200);
[Q1,TQ1] = findpeaks(-EKG1, t, 'MinPeakHeight',100); % NOTE: No ‘S’ Waves In EKG1
[R2,TR2] = findpeaks( EKG2, t, 'MinPeakHeight', 50);
[QS2,TQS2] = findpeaks(-EKG2, t, 'MinPeakHeight', 75);
figure(1)
subplot(2,1,1)
plot(t, EKG1)
hold on
plot(TR1, R1, '^r')
plot(TQ1, -Q1, 'vg')
hold off
grid
axis([0 2 ylim])
legend('EKG', 'R', 'Q')
subplot(2,1,2)
plot(t, EKG2)
hold on
plot(TR2, R2, '^r')
plot(TQS2(1:2:end), -QS2(1:2:end), 'vg')
plot(TQS2(2:2:end), -QS2(2:2:end), 'vb')
hold off
grid
axis([0 2 ylim])
legend('EKG', 'R', 'Q', 'S')
My plot: