MATLAB-based analysis of time-domain heart rate variability metrics from MIT-BIH Arrhythmia Database records to explore differences between normal and pathological cardiac rhythms.
Heart rate variability (HRV) describes the variation in time between consecutive heartbeats. Even when two ECG recordings have a similar mean RR interval, their beat-to-beat variability may reveal important differences in cardiac rhythm.
This project implements a MATLAB workflow for extracting time-domain HRV features from annotated ECG records and exploring their ability to distinguish normal from pathological cardiac rhythms.
The analysis was developed in two stages:
- Comparison of two individual ECG records.
- Automated analysis of a larger collection of records.
The objective is exploratory signal analysis and visual discrimination rather than the development of a clinical diagnostic system.
The ECG signals used in this project were obtained from the MIT-BIH Arrhythmia Database.
The first stage compares two selected records:
- Record 100
- Record 208
The original ECG records were prepared as MATLAB .mat files containing the annotations, R-peak locations, beat types and sampling-frequency information required by the analysis.
The second stage automatically processes 48 records classified into several rhythm categories:
- Normal sinus rhythm (
NSR) - Atrial fibrillation (
AFIB) - Paced rhythm (
PACED) - Complex supraventricular arrhythmias (
ARRH_S_COMPLEX) - Complex ventricular arrhythmias (
ARRH_V_COMPLEX)
Although the original assignment proposed using a representative sample of 10 records, the implemented workflow was extended to analyse 48 records.
The processing pipeline follows these steps:
- Load the ECG annotations and R-peak locations.
- Select beats annotated as normal (
N). - Calculate RR intervals from consecutive R peaks.
- Convert the intervals from samples to seconds using the sampling frequency.
- Apply a physiological filter between 0.3 and 1.8 seconds.
- Extract time-domain HRV metrics.
- Organise the results in MATLAB tables.
- Represent the records in the SDNN–RMSSD feature space.
The mean duration between consecutive valid R peaks.
The standard deviation of the RR intervals, used as a measure of global heart rate variability.
The root mean square of successive RR-interval differences, used to measure short-term beat-to-beat variability.
heart-rate-variability-analysis/
│
├── README.md
├── LICENSE
├── .gitignore
│
├── src/
│ ├── analyze_single_records.m
│ └── analyze_record_dataset.m
│
├── data/
│ └── README.md
│
└── results/
├── README.md
└── figures/
├── README.md
├── single_record_comparison.png
└── healthy_vs_pathological_scatter.png
The analysis successfully processed:
- Record
100: 2,238 valid RR intervals - Record
208: 1,253 valid RR intervals
The extracted time-domain HRV metrics were:
| Record | Classification | Mean RR (s) | SDNN (s) | RMSSD (s) |
|---|---|---|---|---|
| 100 | Normal rhythm | 0.80667 | 0.10069 | 0.13341 |
| 208 | Pathological rhythm | 0.92860 | 0.41709 | 0.59965 |
Although both records have relatively similar mean RR intervals, record 208 presents substantially higher SDNN and RMSSD values, indicating greater beat-to-beat variability.
The automated workflow analysed all 48 selected records:
- 40 records produced valid HRV metrics.
- 8 records contained no valid RR intervals after selecting beats annotated as
Nand applying the physiological filter. - Records without valid intervals were retained in the output tables with
NaNvalues and an explanatory processing status.
The SDNN–RMSSD representation shows that many pathological records present greater variability. However, there is also visible overlap between normal and pathological groups.
These results show that Mean RR, SDNN and RMSSD are useful for exploratory rhythm analysis, but they are not sufficient by themselves to classify every cardiac rhythm reliably.
- Only three time-domain HRV features are analysed.
- Different pathological rhythm categories are grouped together in the final visual comparison.
- Some records may contain too few valid RR intervals after filtering.
- The separation between normal and pathological rhythms is not complete.
- No automatic machine-learning classifier is trained.
Future improvements could include additional time-domain, frequency-domain and nonlinear HRV features, together with supervised classification algorithms.
- MATLAB
- Prepared
.matfiles derived from the MIT-BIH Arrhythmia Database
- Miguel Martín Domínguez
- Adriana Moreno Naranjo
Originally developed jointly with Adriana Moreno Naranjo as a Biomedical Engineering academic project.

