ECG Class for Heart Rate Variability Analysis

Version 1.0.1 (55 MB) by David OK
A class definition for the processing, segmentation, and analysis of electrocardiograph signals.
Updated 23 Dec 2020

View License

The class was written to allow for the easy analysis of ECG signals and their components.
Create an ECG object using:
(varName) = ECG(Signal, SamplingFrequency, Name(optional))

Note: the signal must be inputted as a numeric array.

Once created, varName.init will eliminate offsets, detrend the signal, then identify peaks and calculate:

BPM, SDNN, RMSSD, NN50, pNN50, IBI (mean and range), Low- and High-Frequency Power, and their ratios.

A selection of plot and display commands allow for retrieval of this information.

It also allows for Poincaré Map analysis, frequency analysis of both the signal and its NN interval series, and HRV analysis using historgams and numeric values.

The ECG can be resampled, filtered, and segmented using built in commands, however, data will need to be initialised again following this.

The segmentECG command creates an array of smaller ECGs, each of equal length, determined by either the inputted number of segments or an inputted length. All data for each segment can then be calculated by using varName.segmentInit

A selection of commands then allows the display of data for a selected range of these segments.

All documentation is available by using doc ECG.

Please leave any feedback or bugs encountered in the comments, it would be greatly appreciated.

Cite As

David OK (2024). ECG Class for Heart Rate Variability Analysis (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!


Version Published Release Notes

Tweaked descirptions and fixed some minor errors