SlideShare a Scribd company logo
1 of 13
Download to read offline
ECG SIMULATION USING
       MATLAB

 Principle of Fourier Series




             Presented by
            R. KARTHIK
      B.E. (E.C.E), 6TH Semester
   College of Engineering, Guindy,
           Anna University,
           Chennai – 600025
   e-mail: may_62003@yahoo.co.in
Introduction:
The aim of the ECG simulator is to produce the typical ECG waveforms of different
leads and as many arrhythmias as possible. My ECG simulator is a matlab based
simulator and is able to produce normal lead II ECG waveform.


The use of a simulator has many advantages in the simulation of ECG waveforms.
First one is saving of time and another one is removing the difficulties of taking real
ECG signals with invasive and noninvasive methods. The ECG simulator enables us
to analyze and study normal and abnormal ECG waveforms without actually using
the ECG machine. One can simulate any given ECG waveform using the ECG
simulator.


Significant features of ECG waveform:
A typical scalar electrocardiographic lead is shown in Fig. 1, where the significant
features of the waveform are the P, Q, R, S, and T waves, the duration of each wave,
and certain time intervals such as the P-R, S-T, and Q-T intervals.




                              fig 1.Typical ECG signal
Main features of this simulator:
   • Any value of heart beat can be set
   • Any value of intervals between the peaks (ex-PR interval) can be set
   • Any value of amplitude can be set for each of the peaks
   • Fibrillation can be simulated
   • Noise due to the electrodes can be simulated
   • Heart pulse of the particular ECG wave form can be represented in a separate
       graph


Principle:
Fourier series
 Any periodic functions which satisfy dirichlet’s condition can be expressed as a
series of scaled magnitudes of sin and cos terms of frequencies which occur as a
multiple of fundamental frequency.
                 ∞                      ∞
f (x) = (ao/2) + Σ an cos (nπx / l) + Σ bn sin (nπx / l),
                 n=1                    n=1


ao = (1/ l ) ∫ f (x) dx                       , T = 2l              --      (1)
             T

an = (1/ l ) ∫ f (x) cos (nπx / l) dx         , n = 1,2,3….          --     (2)
             T


bn = (1/ l ) ∫ f (x) sin (nπx / l) dx         , n = 1,2,3….        --       (3)
             T


ECG signal is periodic with fundamental frequency determined by the heart beat. It
also satisfies the dirichlet’s conditions:
   • Single valued and finite in the given interval
   • Absolutely integrable
   • Finite number of maxima and minima between finite intervals
   • It has finite number of discontinuities
Hence fourier series can be used for representing ECG signal.


Calculations:
If we observe figure1, we may notice that a single period of a ECG signal is a
mixture of triangular and sinusoidal wave forms. Each significant feature of ECG
signal can be represented by shifted and scaled versions one of these waveforms as
shown below.
   • QRS, Q and S portions of ECG signal can be represented by triangular
       waveforms
   • P, T and U portions can be represented by triangular waveforms
Once we generate each of these portions, they can be added finally to get the ECG
signal.
Lets take QRS waveform as the centre one and all shiftings takes place with respect
to this part of the signal.


How do we generate periodic QRS portion of ECG signal




                              Fig 2. generating QRS waveform
From equation (1), we have

f(x) = (–bax/l) + a       0 < x < ( l/b )
     = ( bax/l) + a       (– l/b)< x < 0

ao = (1/ l ) ∫ f (x) dx
             T
   = (a/b) * (2 – b )


an = (1/ l ) ∫ f (x) cos (nπx / l) dx
            T
  = ( 2ba / (n2π2 )) * ( 1 – cos (nπ/b))


bn = (1/ l ) ∫ f (x) sin (nπx / l) dx
            T
   = 0 ( because the waveform is a even function)

                 ∞
f (x) = (ao/2) + Σ an cos (nπx / l)
                 n=1




How do we generate periodic p-wave portion of ECG signal




                              Fig 3. generation of p-wave
f(x) = cos ((πbx) /(2l)) (–l/b)< x < (l/b)

ao = (1/ l ) ∫ cos ((πbx) / (2l)) dx
             T
   = (a/(2b))(2-b)


an = (1/ l ) ∫ cos ((πbx) / (2l)) cos (nπx / l) dx
            T
  = (((2ba)/(i2π2)) (1-cos((nπ)/b))) cos((nπx)/l)


bn = (1/ l ) ∫ cos ((πbx) / (2l)) sin (nπx / l) dx
            T
   = 0 ( because the waveform is a even function)

                 ∞
f (x) = (ao/2) + Σ an cos (nπx / l)
                 n=1




Implementation in MATLAB:
Code:
Save the below file as complete.m
x=0.01:0.01:2;
default=input('Press 1 if u want default ecg signal else press 2:n');
if(default==1)
    li=30/72;

    a_pwav=0.25;
    d_pwav=0.09;
    t_pwav=0.16;

    a_qwav=0.025;
    d_qwav=0.066;
    t_qwav=0.166;

    a_qrswav=1.6;
    d_qrswav=0.11;

    a_swav=0.25;
    d_swav=0.066;
t_swav=0.09;

    a_twav=0.35;
    d_twav=0.142;
    t_twav=0.2;

     a_uwav=0.035;
     d_uwav=0.0476;
     t_uwav=0.433;
else
   rate=input('nnenter the heart beat rate :');
   li=30/rate;

  %p wave specifications
  fprintf('nnp wave specificationsn');
  d=input('Enter 1 for default specification else press 2: n');
  if(d==1)
     a_pwav=0.25;
     d_pwav=0.09;
     t_pwav=0.16;
  else
    a_pwav=input('amplitude = ');
    d_pwav=input('duration = ');
    t_pwav=input('p-r interval = ');
    d=0;
  end


  %q wave specifications
  fprintf('nnq wave specificationsn');
  d=input('Enter 1 for default specification else press 2: n');
  if(d==1)
     a_qwav=0.025;
     d_qwav=0.066;
     t_qwav=0.166;
  else
    a_qwav=input('amplitude = ');
    d_qwav=input('duration = ');
    t_qwav=0.1;
    d=0;
  end

  %qrs wave specifications
fprintf('nnqrs wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
   a_qrswav=1.6;
   d_qrswav=0.11;
else
  a_qrswav=input('amplitude = ');
  d_qrswav=input('duration = ');
  d=0;
end


%s wave specifications
fprintf('nns wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
   a_swav=0.25;
   d_swav=0.066;
   t_swav=0.125;
else
  a_swav=input('amplitude = ');
  d_swav=input('duration = ');
  t_swav=0.125;
  d=0;
end


%t wave specifications
fprintf('nnt wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
   a_twav=0.35;
   d_twav=0.142;
   t_twav=0.18;
else
  a_twav=input('amplitude = ');
  d_twav=input('duration = ');
  t_twav=input('s-t interval = ');
  d=0;
end
%u wave specifications
fprintf('nnu wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
     a_uwav=0.035;
     d_uwav=0.0476;
     t_uwav=0.433;
  else
    a_uwav=input('amplitude = ');
    d_uwav=input('duration = ');
    t_uwav=0.433;
    d=0;
  end
end

pwav=p_wav(x,a_pwav,d_pwav,t_pwav,li);


%qwav output
qwav=q_wav(x,a_qwav,d_qwav,t_qwav,li);


%qrswav output
qrswav=qrs_wav(x,a_qrswav,d_qrswav,li);

%swav output
swav=s_wav(x,a_swav,d_swav,t_swav,li);


%twav output
twav=t_wav(x,a_twav,d_twav,t_twav,li);


%uwav output
uwav=u_wav(x,a_uwav,d_uwav,t_uwav,li);

%ecg output
ecg=pwav+qrswav+twav+swav+qwav+uwav;
figure(1)
plot(x,ecg);
Save the below file as p_wav.m
function [pwav]=p_wav(x)
l=1;
a=0.25
x=x+(1/1.8);
b=3;
n=100;
p1=1/l
p2=0
for i = 1:n
  harm1=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
  p2=p2+harm1
end
pwav1=p1+p2;
pwav=a*pwav1;


Save the below file as q_wav.m
function [qwav]=q_wav(x)
l=1;
x=x+l/6
a=0.025;
b=15;
n=100;
q1=(a/(2*b))*(2-b);
q2=0
for i = 1:n
  harm5=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
  q2=q2+harm5;
end
qwav=-1*(q1+q2);


Save the below file as qrs_wav.m
function [qrswav]=qrs_wav(x)
l=1;
a=1;
b=5;
n=100;
qrs1=(a/(2*b))*(2-b);
qrs2=0
for i = 1:n
  harm=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
  qrs2=qrs2+harm;
end
qrswav=qrs1+qrs2;


Save the below file as s_wav.m
function [swav]=s_wav(x)
l=1;
x=x-l/6
a=0.25;
b=15;
n=100;
s1=(a/(2*b))*(2-b);
s2=0
for i = 1:n
  harm3=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
  s2=s2+harm3;
end
swav=-1*(s1+s2);


Save the below file as t_wav.m
function [twav]=t_wav(x)
l=1;
a=0.35
x=x-(1/1.8);
b=7;
n=20;
t1=1/l
t2=0
for i = 1:n
  harm2=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
  t2=t2+harm2
end
twav1=t1+t2;
twav=a*twav1;
Save the below file as u_wav.m
function [uwav]=u_wav(x)
l=1;
a=0.03;
x=x-(1/1.1);
b=21;
n=100;
u1=1/l;
u2=0;
for i = 1:n
  harm4=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
  u2=u2+harm4;
end
uwav1=u1+u2;
uwav=a*uwav1;


precautions:

   • All the files have to be saved in the same folder
   • Save the files in the names mentioned above the code
   • While entering the specification, give the amplitude in mV and duration in
     seconds

Output waveform:

Default Specification

   • Heart beat :72
   • Amplitude:
      P wave 25mV
      R wave 1.60mV
      Q wave 0.025mV
      T wave 0.35mV
   • Duration:
     P-R interval 0.16s
     S-T interval 0.18s
P interval 0.09s
      QRS interval 0.11s
Not all the default values are specified here. They can be obtained from the code of
the simulator from the file complete.m. The user can enter their desired values of
specifications too. Other concepts of the code are simple and are self explanatory.


A typical output for the above specification will be like this:




References:

   • R.S. Khandpur, Handbook of Biomedical Instrumentation
   • Leslie Cromwell, Biomedical Instrumentation and Measurements, Prentice
      Hall of India.
   • MATLAB The Language of Technical Computing, The Mathworks.

More Related Content

What's hot

射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路Simen Li
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABPrashant Srivastav
 
DSP_FOEHU - Lec 10 - FIR Filter Design
DSP_FOEHU - Lec 10 - FIR Filter DesignDSP_FOEHU - Lec 10 - FIR Filter Design
DSP_FOEHU - Lec 10 - FIR Filter DesignAmr E. Mohamed
 
Chapter4 - The Continuous-Time Fourier Transform
Chapter4 - The Continuous-Time Fourier TransformChapter4 - The Continuous-Time Fourier Transform
Chapter4 - The Continuous-Time Fourier TransformAttaporn Ninsuwan
 
CAPACITIVE SENSORS ELECTRICAL WAFER SORT
CAPACITIVE SENSORS ELECTRICAL WAFER SORTCAPACITIVE SENSORS ELECTRICAL WAFER SORT
CAPACITIVE SENSORS ELECTRICAL WAFER SORTMassimo Garavaglia
 
Concept of-complex-frequency
Concept of-complex-frequencyConcept of-complex-frequency
Concept of-complex-frequencyVishal Thakur
 
4 matched filters and ambiguity functions for radar signals-2
4 matched filters and ambiguity functions for radar signals-24 matched filters and ambiguity functions for radar signals-2
4 matched filters and ambiguity functions for radar signals-2Solo Hermelin
 
射頻電子 - [第三章] 史密斯圖與阻抗匹配
射頻電子 - [第三章] 史密斯圖與阻抗匹配射頻電子 - [第三章] 史密斯圖與阻抗匹配
射頻電子 - [第三章] 史密斯圖與阻抗匹配Simen Li
 
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and SystemsDSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and SystemsAmr E. Mohamed
 
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and Systems
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and SystemsDSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and Systems
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and SystemsAmr E. Mohamed
 
Dsp U Lec08 Fir Filter Design
Dsp U   Lec08 Fir Filter DesignDsp U   Lec08 Fir Filter Design
Dsp U Lec08 Fir Filter Designtaha25
 
Dsp 2018 foehu - lec 10 - multi-rate digital signal processing
Dsp 2018 foehu - lec 10 - multi-rate digital signal processingDsp 2018 foehu - lec 10 - multi-rate digital signal processing
Dsp 2018 foehu - lec 10 - multi-rate digital signal processingAmr E. Mohamed
 
First order active rc sections hw1
First order active rc sections hw1First order active rc sections hw1
First order active rc sections hw1Hoopeer Hoopeer
 
Gate 2013 complete solutions of ec electronics and communication engineering
Gate 2013 complete solutions of ec  electronics and communication engineeringGate 2013 complete solutions of ec  electronics and communication engineering
Gate 2013 complete solutions of ec electronics and communication engineeringmanish katara
 
Contemporary photonics serie2
Contemporary photonics serie2Contemporary photonics serie2
Contemporary photonics serie2Nilish Aggarwal
 

What's hot (20)

射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
 
DSP_FOEHU - Lec 10 - FIR Filter Design
DSP_FOEHU - Lec 10 - FIR Filter DesignDSP_FOEHU - Lec 10 - FIR Filter Design
DSP_FOEHU - Lec 10 - FIR Filter Design
 
Chapter4 - The Continuous-Time Fourier Transform
Chapter4 - The Continuous-Time Fourier TransformChapter4 - The Continuous-Time Fourier Transform
Chapter4 - The Continuous-Time Fourier Transform
 
CAPACITIVE SENSORS ELECTRICAL WAFER SORT
CAPACITIVE SENSORS ELECTRICAL WAFER SORTCAPACITIVE SENSORS ELECTRICAL WAFER SORT
CAPACITIVE SENSORS ELECTRICAL WAFER SORT
 
Concept of-complex-frequency
Concept of-complex-frequencyConcept of-complex-frequency
Concept of-complex-frequency
 
4 matched filters and ambiguity functions for radar signals-2
4 matched filters and ambiguity functions for radar signals-24 matched filters and ambiguity functions for radar signals-2
4 matched filters and ambiguity functions for radar signals-2
 
射頻電子 - [第三章] 史密斯圖與阻抗匹配
射頻電子 - [第三章] 史密斯圖與阻抗匹配射頻電子 - [第三章] 史密斯圖與阻抗匹配
射頻電子 - [第三章] 史密斯圖與阻抗匹配
 
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and SystemsDSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
 
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and Systems
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and SystemsDSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and Systems
DSP_2018_FOEHU - Lec 03 - Discrete-Time Signals and Systems
 
Dsp U Lec08 Fir Filter Design
Dsp U   Lec08 Fir Filter DesignDsp U   Lec08 Fir Filter Design
Dsp U Lec08 Fir Filter Design
 
Dsp 2018 foehu - lec 10 - multi-rate digital signal processing
Dsp 2018 foehu - lec 10 - multi-rate digital signal processingDsp 2018 foehu - lec 10 - multi-rate digital signal processing
Dsp 2018 foehu - lec 10 - multi-rate digital signal processing
 
Chapter5
Chapter5Chapter5
Chapter5
 
Ece4510 notes08
Ece4510 notes08Ece4510 notes08
Ece4510 notes08
 
First order active rc sections hw1
First order active rc sections hw1First order active rc sections hw1
First order active rc sections hw1
 
Signals Processing Assignment Help
Signals Processing Assignment HelpSignals Processing Assignment Help
Signals Processing Assignment Help
 
Chebyshev filter
Chebyshev filterChebyshev filter
Chebyshev filter
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
Gate 2013 complete solutions of ec electronics and communication engineering
Gate 2013 complete solutions of ec  electronics and communication engineeringGate 2013 complete solutions of ec  electronics and communication engineering
Gate 2013 complete solutions of ec electronics and communication engineering
 
Contemporary photonics serie2
Contemporary photonics serie2Contemporary photonics serie2
Contemporary photonics serie2
 

Similar to Ecg programa simulado

signal and system Lecture 1
signal and system Lecture 1signal and system Lecture 1
signal and system Lecture 1iqbal ahmad
 
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxPPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxidrissaeed
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGtheijes
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGtheijes
 
On The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationOn The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationCSCJournals
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing ssuser2797e4
 
Matlab 2
Matlab 2Matlab 2
Matlab 2asguna
 
Signal classification of signal
Signal classification of signalSignal classification of signal
Signal classification of signal001Abhishek1
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfArijitDhali
 
detectıon of dıseases usıng ECG signal
detectıon of dıseases usıng ECG signaldetectıon of dıseases usıng ECG signal
detectıon of dıseases usıng ECG signalSerhat Dağ
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxrealme6igamerr
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1Janardhana Raju M
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-modelajaydev1111
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Alexander Litvinenko
 
02_signals.pdf
02_signals.pdf02_signals.pdf
02_signals.pdfMituBaral2
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidXavier Davias
 
Signals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSignals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSelamawitHadush1
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Alexander Litvinenko
 

Similar to Ecg programa simulado (20)

Ecg
EcgEcg
Ecg
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
signal and system Lecture 1
signal and system Lecture 1signal and system Lecture 1
signal and system Lecture 1
 
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxPPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
 
On The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationOn The Fundamental Aspects of Demodulation
On The Fundamental Aspects of Demodulation
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing
 
Matlab 2
Matlab 2Matlab 2
Matlab 2
 
Signal classification of signal
Signal classification of signalSignal classification of signal
Signal classification of signal
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdf
 
detectıon of dıseases usıng ECG signal
detectıon of dıseases usıng ECG signaldetectıon of dıseases usıng ECG signal
detectıon of dıseases usıng ECG signal
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptx
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-model
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
 
02_signals.pdf
02_signals.pdf02_signals.pdf
02_signals.pdf
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
 
Signals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSignals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptx
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Ecg programa simulado

  • 1. ECG SIMULATION USING MATLAB Principle of Fourier Series Presented by R. KARTHIK B.E. (E.C.E), 6TH Semester College of Engineering, Guindy, Anna University, Chennai – 600025 e-mail: may_62003@yahoo.co.in
  • 2. Introduction: The aim of the ECG simulator is to produce the typical ECG waveforms of different leads and as many arrhythmias as possible. My ECG simulator is a matlab based simulator and is able to produce normal lead II ECG waveform. The use of a simulator has many advantages in the simulation of ECG waveforms. First one is saving of time and another one is removing the difficulties of taking real ECG signals with invasive and noninvasive methods. The ECG simulator enables us to analyze and study normal and abnormal ECG waveforms without actually using the ECG machine. One can simulate any given ECG waveform using the ECG simulator. Significant features of ECG waveform: A typical scalar electrocardiographic lead is shown in Fig. 1, where the significant features of the waveform are the P, Q, R, S, and T waves, the duration of each wave, and certain time intervals such as the P-R, S-T, and Q-T intervals. fig 1.Typical ECG signal
  • 3. Main features of this simulator: • Any value of heart beat can be set • Any value of intervals between the peaks (ex-PR interval) can be set • Any value of amplitude can be set for each of the peaks • Fibrillation can be simulated • Noise due to the electrodes can be simulated • Heart pulse of the particular ECG wave form can be represented in a separate graph Principle: Fourier series Any periodic functions which satisfy dirichlet’s condition can be expressed as a series of scaled magnitudes of sin and cos terms of frequencies which occur as a multiple of fundamental frequency. ∞ ∞ f (x) = (ao/2) + Σ an cos (nπx / l) + Σ bn sin (nπx / l), n=1 n=1 ao = (1/ l ) ∫ f (x) dx , T = 2l -- (1) T an = (1/ l ) ∫ f (x) cos (nπx / l) dx , n = 1,2,3…. -- (2) T bn = (1/ l ) ∫ f (x) sin (nπx / l) dx , n = 1,2,3…. -- (3) T ECG signal is periodic with fundamental frequency determined by the heart beat. It also satisfies the dirichlet’s conditions: • Single valued and finite in the given interval • Absolutely integrable • Finite number of maxima and minima between finite intervals • It has finite number of discontinuities
  • 4. Hence fourier series can be used for representing ECG signal. Calculations: If we observe figure1, we may notice that a single period of a ECG signal is a mixture of triangular and sinusoidal wave forms. Each significant feature of ECG signal can be represented by shifted and scaled versions one of these waveforms as shown below. • QRS, Q and S portions of ECG signal can be represented by triangular waveforms • P, T and U portions can be represented by triangular waveforms Once we generate each of these portions, they can be added finally to get the ECG signal. Lets take QRS waveform as the centre one and all shiftings takes place with respect to this part of the signal. How do we generate periodic QRS portion of ECG signal Fig 2. generating QRS waveform
  • 5. From equation (1), we have f(x) = (–bax/l) + a 0 < x < ( l/b ) = ( bax/l) + a (– l/b)< x < 0 ao = (1/ l ) ∫ f (x) dx T = (a/b) * (2 – b ) an = (1/ l ) ∫ f (x) cos (nπx / l) dx T = ( 2ba / (n2π2 )) * ( 1 – cos (nπ/b)) bn = (1/ l ) ∫ f (x) sin (nπx / l) dx T = 0 ( because the waveform is a even function) ∞ f (x) = (ao/2) + Σ an cos (nπx / l) n=1 How do we generate periodic p-wave portion of ECG signal Fig 3. generation of p-wave
  • 6. f(x) = cos ((πbx) /(2l)) (–l/b)< x < (l/b) ao = (1/ l ) ∫ cos ((πbx) / (2l)) dx T = (a/(2b))(2-b) an = (1/ l ) ∫ cos ((πbx) / (2l)) cos (nπx / l) dx T = (((2ba)/(i2π2)) (1-cos((nπ)/b))) cos((nπx)/l) bn = (1/ l ) ∫ cos ((πbx) / (2l)) sin (nπx / l) dx T = 0 ( because the waveform is a even function) ∞ f (x) = (ao/2) + Σ an cos (nπx / l) n=1 Implementation in MATLAB: Code: Save the below file as complete.m x=0.01:0.01:2; default=input('Press 1 if u want default ecg signal else press 2:n'); if(default==1) li=30/72; a_pwav=0.25; d_pwav=0.09; t_pwav=0.16; a_qwav=0.025; d_qwav=0.066; t_qwav=0.166; a_qrswav=1.6; d_qrswav=0.11; a_swav=0.25; d_swav=0.066;
  • 7. t_swav=0.09; a_twav=0.35; d_twav=0.142; t_twav=0.2; a_uwav=0.035; d_uwav=0.0476; t_uwav=0.433; else rate=input('nnenter the heart beat rate :'); li=30/rate; %p wave specifications fprintf('nnp wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_pwav=0.25; d_pwav=0.09; t_pwav=0.16; else a_pwav=input('amplitude = '); d_pwav=input('duration = '); t_pwav=input('p-r interval = '); d=0; end %q wave specifications fprintf('nnq wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_qwav=0.025; d_qwav=0.066; t_qwav=0.166; else a_qwav=input('amplitude = '); d_qwav=input('duration = '); t_qwav=0.1; d=0; end %qrs wave specifications
  • 8. fprintf('nnqrs wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_qrswav=1.6; d_qrswav=0.11; else a_qrswav=input('amplitude = '); d_qrswav=input('duration = '); d=0; end %s wave specifications fprintf('nns wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_swav=0.25; d_swav=0.066; t_swav=0.125; else a_swav=input('amplitude = '); d_swav=input('duration = '); t_swav=0.125; d=0; end %t wave specifications fprintf('nnt wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_twav=0.35; d_twav=0.142; t_twav=0.18; else a_twav=input('amplitude = '); d_twav=input('duration = '); t_twav=input('s-t interval = '); d=0; end %u wave specifications fprintf('nnu wave specificationsn'); d=input('Enter 1 for default specification else press 2: n');
  • 9. if(d==1) a_uwav=0.035; d_uwav=0.0476; t_uwav=0.433; else a_uwav=input('amplitude = '); d_uwav=input('duration = '); t_uwav=0.433; d=0; end end pwav=p_wav(x,a_pwav,d_pwav,t_pwav,li); %qwav output qwav=q_wav(x,a_qwav,d_qwav,t_qwav,li); %qrswav output qrswav=qrs_wav(x,a_qrswav,d_qrswav,li); %swav output swav=s_wav(x,a_swav,d_swav,t_swav,li); %twav output twav=t_wav(x,a_twav,d_twav,t_twav,li); %uwav output uwav=u_wav(x,a_uwav,d_uwav,t_uwav,li); %ecg output ecg=pwav+qrswav+twav+swav+qwav+uwav; figure(1) plot(x,ecg);
  • 10. Save the below file as p_wav.m function [pwav]=p_wav(x) l=1; a=0.25 x=x+(1/1.8); b=3; n=100; p1=1/l p2=0 for i = 1:n harm1=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); p2=p2+harm1 end pwav1=p1+p2; pwav=a*pwav1; Save the below file as q_wav.m function [qwav]=q_wav(x) l=1; x=x+l/6 a=0.025; b=15; n=100; q1=(a/(2*b))*(2-b); q2=0 for i = 1:n harm5=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); q2=q2+harm5; end qwav=-1*(q1+q2); Save the below file as qrs_wav.m function [qrswav]=qrs_wav(x) l=1; a=1; b=5; n=100; qrs1=(a/(2*b))*(2-b);
  • 11. qrs2=0 for i = 1:n harm=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); qrs2=qrs2+harm; end qrswav=qrs1+qrs2; Save the below file as s_wav.m function [swav]=s_wav(x) l=1; x=x-l/6 a=0.25; b=15; n=100; s1=(a/(2*b))*(2-b); s2=0 for i = 1:n harm3=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); s2=s2+harm3; end swav=-1*(s1+s2); Save the below file as t_wav.m function [twav]=t_wav(x) l=1; a=0.35 x=x-(1/1.8); b=7; n=20; t1=1/l t2=0 for i = 1:n harm2=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); t2=t2+harm2 end twav1=t1+t2; twav=a*twav1;
  • 12. Save the below file as u_wav.m function [uwav]=u_wav(x) l=1; a=0.03; x=x-(1/1.1); b=21; n=100; u1=1/l; u2=0; for i = 1:n harm4=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); u2=u2+harm4; end uwav1=u1+u2; uwav=a*uwav1; precautions: • All the files have to be saved in the same folder • Save the files in the names mentioned above the code • While entering the specification, give the amplitude in mV and duration in seconds Output waveform: Default Specification • Heart beat :72 • Amplitude: P wave 25mV R wave 1.60mV Q wave 0.025mV T wave 0.35mV • Duration: P-R interval 0.16s S-T interval 0.18s
  • 13. P interval 0.09s QRS interval 0.11s Not all the default values are specified here. They can be obtained from the code of the simulator from the file complete.m. The user can enter their desired values of specifications too. Other concepts of the code are simple and are self explanatory. A typical output for the above specification will be like this: References: • R.S. Khandpur, Handbook of Biomedical Instrumentation • Leslie Cromwell, Biomedical Instrumentation and Measurements, Prentice Hall of India. • MATLAB The Language of Technical Computing, The Mathworks.