Can anyone help me run this code to detect the R peaks in my ecg signal and then modify it to obtain the bpm?
4 views (last 30 days)
Show older comments
%clear stuff
clf
clear
clc
%Load the ECG/EKG data
EKG = load('Child_E1SISO.mat')
EKG_1 = EKG.val(1,:);
EKG_2 = EKG.val(2,:);
%time step vector
ts = (0:10/length(EKG_1):10-10/length(EKG_1));
%plot data
plot(ts, EKG_1)
hold on;
title('EKG Data (Channel 1)')
xlabel('Time (in seconds)')
ylabel('EKG amplitude')
%[PkAmp, PkTime] = findpeaks(Displacement)
[PkAmp, PkTime] = findpeaks(EKG_1, 'MinPeakHeight', 1100);
Actual_Time = PkTime/length(EKG_1);
I am trying to get the Rpeaks and then obtain the heart rate of the signal in bpm.
2 Comments
Cris LaPierre
on 16 May 2023
Child_E1SISO.mat does not contain a variable named val, and the variable that it does contain (Child_E1) only has a single column of data.
Answers (1)
Cris LaPierre
on 16 May 2023
I'd suggest doing this interactively in a live script using the Find Local Extrema live task. There, you can interactively adjust the settings until you obtain the points you want, and then either turn that into code, or just work with the output.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!