SNR of ECG
Version 1.0.1 (450 KB) by
William Rose
Estimate signal to noise ratio for electrocardiogram.
Function file ecgSNR.m implements the function that estimates the signal to noise ratio for the ECG.
Script file ecgSNRtest.m demonstrates the use of ecgSNR().
Script file makeECGsimSNRfilt.m generates the data file ecgSNRsim2filt.mat, which is used for testing.
Data file ecgSimNoNoise.txt is a simulated ECG, 1 beat, 1 second (i.e. heart rate=60 beats/minute), Fs=1000 Hz. Some of the waves have sharp corners. This file is used by makeECGsimSNRfilt.m.
Data file ecgSNRsim2filt.mat contains array six simlated ECGs. Each column is a 10-seocnd-long simulated ECG. This is the duration of a typical ECG rhythm strip. The noise amplitude increases across the columns. The ECG in column 1 has no added noise. This file is used by script ecgSNRtest.m, to demonstrate the use of ecgSNR(). The sampling rate is 1000 Hz and the heart rate of the simulated ECGs is 60 bpm.
The concept underlying function ecgSNR() is that the ECG signal power is in the band 0.67 to 150 Hz. These frequencies are chosen to agree with the bandpass filter limits recommended by the 2007 American Heart Association ECG Guidlelines. Noise (other than line noise) is assumed to be white. The power of the noise in the entire frequency band, from 0 to the Nyquist frequency, is estimated from the power outside the 0.67 to 150 Hz band.
The user can change variable lineFilter from False to True in the code, if there is noise at the line frequency. When lineFilter is true, the power at the line frequency and at 2 times the line frequency is assumed to be noise, and the SNR numerator and denominator are adjusted accordingly.
The user can change the line frequency (fLIne) from 60 to 50 Hz, if desired.
This function was inspired by the question "Signal quality assessment with SNR in Matlab" from Elzbieta, Matlab Answers, 2024-11-29. See additional discussion there.
Cite As
William Rose (2025). SNR of ECG (https://uk.mathworks.com/matlabcentral/fileexchange/177229-snr-of-ecg), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
