detectEcgWithAngle(​ecg, fSInHz, varargin): Heartbeat detection using sample-to-sample angle

Implementation of the R-peak detector using the angle between successive samples.


Updated Thu, 08 Feb 2018 14:42:19 +0000

View License

This is the complete implementation of the R-peak detector from Song, Cho, Kim & Lee proposed in "New real-time heartbeat detection method using the angle of a single-lead electrocardiogram", Computers in Biology and Medicine, 59 (2015). DOI: 10.1016/j.compbiomed.2015.01.05.
The detector is robust to noise and peak reversal and uses a single lead ecg signal. See the header of the function for a detailed description.

Cite As

David J. Mack (2023). detectEcgWithAngle(ecg, fSInHz, varargin): Heartbeat detection using sample-to-sample angle (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on ECG / EKG in Help Center and MATLAB Answers

Inspired by: Plot (Big)

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

[!!!] Detection results may have changed for sampling rates ~= 200 Hz.
[FIX] Reintroduced the DESIGNFILT call for sampling rates ~= 200 Hz to get the filter coefficient right.
[FIX] Crash when plotting detection results with only 1 peak.

[FIX] Crash when plotting empty detection results.
[FIX] Crash when plotting data with all-normal rr intervals.
[ADD] New optional input 'minTStartInSec' to remove erroneous detections at the start of the recording.

Forgot to mention another modification:
[MOD] The transfer function representation of the bandpass-filter is now to avoid calling the slow DESIGNFILT method every time. This also removes the according dependency.
- [FIX] Error in the description which stated useBaselineCorrection as being false by default, which it isn't.
- [MOD] If rPeakAmps is not requested as output and showPlot==false, baseline correction will now silently be turned off for speed.

[FIX] Checks for optional dependencies now work properly.