5. We are often asked to confirm that a given filter design has the intended effect. This is often achieved
using **MATLAB** or **numpy** (or any similar computational environment) using a white noise signal-
one that (approximately) contains all valid frequencies at approximately the same amplitude. In
practice, we can generate this using a random number generator that produces random values
between 0 and 1-in **MATLAB** this would be **rand**-shifting it to have a mean of zero (i.e., subtract
0.5 from all values, such that the mean is 0 and, therefore, X[0] = 0), passing the resultant zero-
Page 2 of 3
BME 3020C
Sensing and Measurement
Summer 2024
mean signal through the convolutional kernel, and then evaluating how the frequency spectrum of
the output differs from that of the input. We will here evaluate your filter from **Problem 2** in this
manner.
a. First, use **rand** (or whatever is appropriate for your computational tool!) to generate a
sequence of (at least) 2048 random values having a zero mean. (If you are using **MATLAB**,
just subtract 0.5 from all values in the vector!)
b. Use **fft** and **fftshift** to plot the magnitude of the frequency spectrum for your noise
signal (i.e., what you generated in part a.). To make this a truly useful spectrum, you will want
to use **fftshift** as well as to define an x-axis scale to use with **plot**. For this latter, recall
that in an N-point DFT, the Nth value corresponds to $F_s$ (here taken to be 10 kHz), and the
value at $\frac{N}{2}$ corresponds to one-half this value. Assuming you did not limit the length of the FFT
performed, you should now have (at least) 2048 values that are to be mapped to encompass
$f \in [-\frac{F_s}{2}, \frac{F_s}{2})$. Note that this particular range assumes you have used **fftshift**. Once you
do have a magnitude spectrum that covers $f \in [-5000,5000)$ Hz, confirm the spectrum is
"flat" in the sense that there is not a clear low-, high-, or band-pass/reject structure. (If so,
re-run your random sequence generation process...you just got unlucky, which is improbable,
but NOT impossible).
c. Convolve your noise signal with the convolutional kernel you generated in **Problem 2**. If you
are using **MATLAB**, be sure to use the 'same' option with **conv** to trim the result to match
the length of the noise signal. (Similar options exist in other computational environments!)
d. Plot the magnitude of the frequency spectrum for your filtered signal. To make this a useful
spectrum, you will once again want to use **fftshift** and define an x-axis. Once you have
achieved an effective plot of the output frequency spectrum, compare the spectrum with
that obtained in part b. and confirm/refute that the passband corresponds to the targeted
range of frequencies.