Pole Zero Maps & Notch Filters

Solution

Lab8sol

Contents

Estimating Frequency Response from Pole-Zero Map

%Using the poles and zeros given, we derive the simplified transfer
%functions:

$$H_{1}(z)= 1 +0.25z^{-1}-0.75z^{-2}$$

$$H_{2}(z)= 1 -z^{-1}+z^{-2}-z^{-3}$$

Using the freqz() function, we can get and then plot the magnitude response.

clear all; close all; clc;
[h1 w]=freqz([1 0.25 -0.75],1,250);
[h2 w]=freqz([1 -1 1 -1],1,250);
figure;
plot(w,abs(h1));
hold on
plot(w,abs(h2));
xlabel('Normalized frequency');
ylabel('Magnitude');
title('Magnitude Response');
legend('H_1','H_2');

Cascaded FIR Notch Filter for ECG

Load the ECG data

load('ECG.mat');
load('time.mat');
Fs=720;
time_upperBoundary=max(time);

Estimate and display spectrum.

spectrum= -Fs/2:1/time_upperBoundary:Fs/2-1/time_upperBoundary;
ECGmag = (1/length(ECG)).*abs(fftshift(fft(ECG)));
figure;
stem(spectrum,ECGmag);
xlabel('Frequency/Hz');
ylabel('Magnitude');
title('Raw ECG signal spectrum');

Design of notch filter using fir1() Since 50 Hz component needs to be filtered out, we design a band reject filter , with the rejection band being between 49 and 51 Hz. Hence their normalized frequency equivalents are sed as boundaries.

taps = 400;                  % Number of taps / Order of filter
fir_filter = fir1(taps,2.*[49/Fs 51/Fs],'stop');
filtered_ECG = conv(ECG,fir_filter,'same');
f_ECGmag = (1/length(filtered_ECG)).*abs(fftshift(fft(filtered_ECG)));
figure;
stem(spectrum,f_ECGmag);
xlabel('Frequency/Hz');
ylabel('Magnitude');
title('Filtered ECG signal spectrum');

Robotics & Dynamic Systems Lab