## Description

In this assignment, you will reinforce what we did in lecture today regarding MATLAB’s filter toolbox.

For each of the following questions, you will create a filter, create magnitude-phase

plots for the filter and apply the filter to a signal. Follow these steps:

• Generate MATLAB code for filters using the filter design toolbox in the signal

processing toolbox (filterDesigner).

• Create a filter object by calling the generated code.

• Use the DSP toolbox’s version of freqz on the filter object. Make sure to

include the sampling frequency in the function call as this is hardly mentioned

in the documentation. For example, if f ilter is a filter object, n is the number

of points (you can use 1024) and fs is the sampling frequency, run [H, f] =

freqz(f ilter, n, fs). Note I use f instead of w since by including the sampling

frequency, MATLAB scales the frequencies from [0, π] to [0, fs/2]. Hence these

frequencies have units of Hertz. Keep that in mind when including units in

your plots and setting the axis limits.

• Create magnitude-phase plots akin to homework 6 except for the difference

mentioned above regarding f.

• Apply the filter to the signal using filter.

• Lastly, plot the Fourier Transform of the final result using fft and plot. Refer

to the notes for the proper way to use fft and obtain the proper scaling.

This may seem daunting, but with properly defined functions, you may only have to

do most of the work once. However, I still want unique titles for plots (maybe pass

in a string?).

1. Generate a signal that consists of a sum of sine waves of frequencies 1 to 50

kHz. Set t to be from 0 to 2 seconds, using an interval of 0.001s.

signal =

50000

X

f=1

sin(2πf t)

2. Create a Butterworth lowpass filter with a sampling frequency of Fs = 100

kHz, a passband frequency of Fpass = 10 kHz, a stopband frequency of Fstop

= 20 kHz, a passband attenuation of Apass = 5dB, and a stopband attenuation

of Astop = 50dB.

1

ECE-210B Homework 7

3. Create a Chebychev I highpass filter with a sampling frequency of Fs = 100

kHz, a passband frequency of Fpass = 35 kHz, a stopband frequency of Fstop

= 15 kHz, a passband attenuation of Apass = 2dB, and a stopband attenuation

of Astop = 40dB.

4. Create a Chebychev II bandstop filter with a sampling frequency of Fs = 100

kHz, a passband frequency of below the frequency Fpass1 = 5 kHz and above

Fpass2 = 45 kHz, a stopband frequency of between Fstop1 = 15 kHz Fstop2 =

35kHz, a passband attenuation of Apass = 5dB, and a stopband attenuation

of Astop = 50dB.

5. Create a Elliptic bandpass filter with a sampling frequency of Fs = 100 kHz, a

stopband frequency of below the frequency Fstop1 = 15 kHz and above Fstop2

= 35 kHz, a passband frequency of between Fpass1 = 20 kHz Fpass2 = 30

kHz, a passband attenuation of Apass = 5dB, and a stopband attenuation of

Astop = 50dB.

2