Heart Arrhythmia Detection and its Analysis using MATLAB

DOI : 10.17577/IJERTV10IS110176

Download Full-Text PDF Cite this Publication

Text Only Version

Heart Arrhythmia Detection and its Analysis using MATLAB

Anusha Jami

Dpt: Electronics and Communication Engineering Vellore Institute Technology, Vellore

Tamil Nadu, India

Challa Jaya Simha

Dpt: Electronics and Communication Engineering Vellore Institute Technology, Vellore

Tamil Nadu, India

AbstractThe heart condition is monitored by the Electrocardiogram (ECG) signal. The abnormal conditions of the heart results in the artificial Arrhythmia. This paper deals with the study and analysis of ECG signal by means of MATLAB tool effectively. The study of ECG signal and Arrhythmia detection and analysis includes generation and simulation of ECG signal, real time ECG data analysis, ECG signal de-noising and processing using filters and detrending technique, detection of QRS peaks and its Locations, calculation of RR and QRS interval, calculation of heart beat rate using the MATLAB software, detection of any abnormalities in ECG by using the above parameters. This way the person having abnormal rhythm is detected. Previous, analysis of Arrhythmia is done only based on heart rate but in this paper even other parameters RR and QRS intervals are calculated and are used along with heart beat rate to detect any of the abnormalities in ECG. The accuracy and precision of this analysis is calculated and shown. Thus, the proper utilization of MATLAB functions and toolbox can lead us to work with the ECG signals processing and analysis in real time and simulation done with good accuracy and is convenient. Thus, the method serves as an easy technique for studying cardiac abnormality.

KeywordsArrhythmia,ECG analysis, R-R interval, QRS pattern, de-noising,Filters,detrending,heart beat rate.


    ECG is the most easily accessible bioelectric signal that provides the doctors with accurate and reasonable information regarding heart condition of the patient. Many of the cardiac problems which persists are visible in the form of distortions in the electrocardiogram (ECG). The major tasks involved in diagnosing the heart condition is analysing each heart beat and calculating the heart beat rate and co-relating the distortions found therein with the various heart diseases. ECG signal consists of some few main components such as the segments, intervals, and waves which are studied and evaluated based on the size, and duration time or interval. The heart rhythm is determined by the detection and analysis of these different components. The Abnormal rhythm of the heart is called arrhythmia (or dysrhythmia) and is indicated when above mentioned components vary with the expected norm. Any deviation from the predefined pattern of the in terms of amplitude or time duration indicates the abnormality in functioning of the human heart.

    The typical ECG signal consists of P, QRS, T, U components. The QRS complex a vital role in identifying the problems that occur with the functioning of heart. If any problems are associated with the heart, then the QRS complex lengthens or

    widens or becomes shorter. The abnormalities in the rhythm are mainly observed with the help of parameters QRS duration, R-R interval and heart beat rate.

    Fig.1. Components of ECG signal


    Fig-2: Block Diagram for one data sample

    Fig-3: Block Diagram



Signal processing is a major challenge as the actual signal value will be 0.5mV in an offset environment of 300mV. The factors such as the AC power-supply interference, RF interference from surgery equipment, and implanted devices like pace makers and physiological monitoring systems can also interference the noise to the ECG signal. So, it is important to remove the noise from the ECG signal before it is analysed and processed else may cause deviations from the actual and correct readings. The main sources of noise are listed below and are removed by using the following filters mentioned.

  • Baseline wander noise is removed using high pass FIR filter with cut off frequency 150Hz and a low pass FIR filter with cut off frequency 0.05Hz.

    MATLAB syntax for designing the above high pass FIR filter:

    >> b=fir1(Number_of_order,1/3600,'high'); y = y + 25*filter(b,1,5*val);

    MATLAB syntax for designing the above Low pass FIR filter:

    >> b=fir1(Number_of_order,150/180); y = y + filter(b,1,val);

  • powerline noise is removed using 100 coefficient and 1000 coefficient band- stop FIR filter of cut off frequency


MATLAB syntax for designing the above high pass FIR filter:

>> y = y + filter(bandstop_100,1,val);


The parameters used for the analysis of the Arrhythmia is the QRS complex which is calculated with the help of QRS duration, R-R interval and heart rate. The process to find its calculation and location is described below.

Calculating R, Q, S peak and its location: The standard QRS interval is considered as 0.094 and in order to access the samples and round them to the nearest integer less than or equal to that value.

MATLAB syntax:

>>Sample= floor ((Sampling frequency)*(Standard QRS interval)/2)

QRS duration: The duration of QRS complex of ECG can be calculated by dividing the number of samples between the QRS complex and the sampling frequency of the signal. By calculating the duration, we can know whether the signal is abnormal or normal. As per the standards, the standard QRS duration of a normal ECG signal ranges from 0.06 to 0.10 seconds.

    1. interval: This is the longest amplitude peak in ECG signal. It is calculated by dividing the number of samples between two R peaks and sampling frequency of the signal. This plays a vital role in finding the abnormalities of a signal.

      For calculating the region of R-R and QRS, for loop of length with range from 1 till the length of the R-1 and the difference of the consecutive samples is the R-R interval are used.

      >>R-R region (k)=R location(k+1)-R location(k)

      >>QRS region (k)=S location-Q location

      For calculating the R-R and QRS intervals, mean of the normalized locations of R and Q-S are used.

      >>R-R interval=mean(R-R region/Sampling frequency)

      >>QRS interval=mean(R-R region/Sampling frequency)

      Calculation of Normal and Abnormal Heart beat rates: Heart beat rate= (1/60)*R-R interval

      Normal Heart beat rate= Heartbeat of patient whose actual is 1 Abnormal Heart beat rate=Heartbeat of patient whose actual is 0 Mean Normal Heart beat rate= Mean(Heartbeat of patient whose actual is 1)

      Mean Abnormal Heart beat rate= Mean(Heartbeat of patient whose actual is 0)

      Distance Normal=absolute(normal- mean normal heart beat) Distance Abnormal=absolute(normal- mean Abnormal heart beat)

      Criteria for normal and abnormal Heart beat rate:

      1. 0.06<QRS interval<Standard QRS interval

      2. Distance Normal<Distance Abnormal

Only if both the conditions are satisfied then we may say that Heart beat rate of a patient is normal.

Fig-4: Identification of Normal or Abnormal characteristics

Fig-5: Identification of Normal or Abnormal characteristics

Calculation of Accuracy and Precision:

of Arythmia in a patient.


Parameters used

RR interval (seconds)

Heartrate (beats/min)

QRS duration (seconds)







Signal A





Signal B





Signal C





Signal D





Signal E





Signal F





Signal G





Table 1: ECG Signal Features and their Respective Values





Difference=Actual-Result A=(difference=0 and actual=0) B=(difference=0 and actual=1) C=(difference~=0 and actual=1) D=(difference~=0 and actual=0)

Accuracy=((A+B)/(A+B+C+D))*100 Precision=(B/B+C)*100

Now a specific data which is 100m.mat along with its correspondi header file, ATR file and data file are loaded and is displayed.

Fig-6: Calculation of Accuracy and Precision

Detection of QRS peaks of 100m.mat:

Sampling frequency=length(value)/time

where value is the sample of a signal at a particular time instant.

Then the base wander line noise and power line noise of the data

sample are removed as described in the above section.

Detrending of Noise removed data sample:

Linear de trends are removed from the data sample. Detrended data sample=Noise removal data sample-Signal with trends

The signal is now smoothened using sgolayfilt filter. Detection of Arythmia: The sm.info and the sm.mat formats of 4 signals are loaded. Now the ECG signal corresponding to

the normal and abnormal behaviour we may detect the presence

Fig-7: QRS peaks identification of 1st data sample

Fig-8: QRS peaks identification of 2nd data sample

Fig-9: QRS peaks identification of 3rd data sample

Fig-10: QRS peaks identification of 4th data sample

Fig-11: QRS peaks identification of 5th data sample

Fig-12: 100.dat ECG signal

Fig-13: Detrended 100.dat ECG signal

Fig-14: RS peaks identification of 100.dat signal

Fig-15: Identification of the ECG of foetus in 4 abdomens


The Heart Arrhythmia detection is successfully done considering all the factors. All the necessary parameters P, QRS, T, U components are analysed and are used for detection of any abnormalities in the heart.Most of the cardiac problems persisting can thus be identified due to the irregularities in the ECG of the person by not only calculating the heart rate but also considering above parameters.The conditons of normalECG signal are considered and compared with the persons ECG to check the person has normal or abnormal or heart rate.This way the complete analysis and detection of heart Arrhythmia is done easily and efficiently.


ANUSHA JAMI,Currently studying at VIT university, vellore , school of Electronics and communication Engineering (SENSE)


,Currently studying at VIT university, vellore , school of Electronics and communication Engineering (SENSE)


  1. Jindal, Bhawna & Saudagar, & Ekta, & Devi, Reeta. (2018). Matlab Based GUI for ECG Arrhythmia Detection Using Pan-Tompkin Algorithm. 754-759. 10.1109/PDGC.2018.8745865.

  2. Malik, Gorav & Kumar, Yatindra & Panda, M.K.. (2017). Cardiac arrhythmia detection in ECG signals by feature Extraction and support vector machine. 241-244. 10.15439/2017R63.

  3. Priya and M. Singh, "MATLAB based ECG signal noise removal and its analysis," 2015 2nd International Conference on Recent Advances in Engineering & Computational Sciences (RAECS), 2015, pp. 1-5, doi: 10.1109/RAECS.2015.7453385.

  4. JOSHI, ANAND & TOMAR, ARUN & TOMAR, MANGESH. (2014). A Review Paper on Analysis of Electrocardiograph (ECG) Signal for the Detection of Arrhythmia Abnormalities. International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering. 03. 12466-12475. 10.15662/ijareeie.2014.0310028.

  5. M.K. Islam, A. N. M. M. Haque, G. Tangim, T. Ahammad, and

    M.R.H. Khondokar, Study and Analysis of ECG Signal Using MATLAB & LABVIEW as Effective Tools, International Journal of Computer and Electrical Engineering, vol. 4, no. 3, pp. 404-408, June 2012.

  6. Rajni, Rajni & Kaur, Inderbir. (2013). Electrocardiogram Signal Analysis – An Overview. International Journal of Computer Applications. 84. 22-25. 10.5120/14590-2826.

Leave a Reply