Question: The code below generates a 3 - beat ECG signal and then adds powerline interference at 6 0 Hz along with its harmonics at 1
The code below generates a beat ECG signal and then adds powerline interference at Hz along with its harmonics at Hz and Hz Run the code in MATLAB and explain the purpose of the chosen filter.
Then, add an additional harmonic at Hz to the noise signal and modify the filter by adding a zero at this frequency to remove the Hz harmonic from the ECG signal. Include all resulting figures with a brief explanation for each.
MATLAB CODE:
clear all, close all
Step : Define parameters
fs ; Sampling frequency Hz
T ; Duration in seconds for beats
t :fs:Tfs; Time vector
Step : Create sine signal pretend ECG
singlebeat sin pi t:end; Replace with a sine wave for testing
singlebeat singlebeat maxabssinglebeat; Normalize signal
numbeats ;
ecgsignal repmatsinglebeat, numbeats;
tecg :fs:lengthecgsignalfs;
Step : Add power line interference
fnoise; fnoise; fnoise;
noise sin pi fnoise tecg
sin pi fnoise tecg
sin pi fnoise tecg;
noisyecg ecgsignal noise;
Step : Plot noisy ECG signal
figure; plottecg, noisyecg, r;
titleNoisy Sine Signal';
xlabelTime s; ylabelAmplitude; grid on;
Step : Power Spectral Density
psdvalues, f pwelchnoisyecg, fs;
figure; plotflogpsdvalues;
titlePower Spectral Density'; xlabelFrequency Hz;
ylabelPowerFrequency dBHz;
grid on;
Step : Design comb filter
ffnoise fnoise fnoise;
z ;
for i :lengthf
theta pi fi fs;
z z expjtheta expjtheta;
end
b polyz; a ; Filter coefficients
Step : Apply comb filter
filteredecg filterb a noisyecg;
Step : Plot filtered ECG
figure; plottecg, filteredecg, b;
titleFiltered Sine Signal';
xlabelTime s; ylabelAmplitude;
grid on;
Step : Frequency Response
figure; freqzb a fs;
titleFrequency Response of Comb Filter';
grid on;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
