OC3150 LAB 3
Objective
To study the discrete Fourier transform, sampling
techniques, and the phenomena of aliasing and leakage.
Things to Keep in Mind
The FFTSPA program below will use your input information to generate a
continuous wave signal (NOT plotted), then it will sample N points from the
signal. Sampling frequency is one point every dt seconds. FFTSPA then
"connects the dots" of the N points to plot your sampled data
in the top half of a figure window. Finally, it performs a Fourier Transform
on the N points and generates an amplitude spectrum, which is plotted on the
lower half of the figure window.
-
The period of analysis or total sampling time = T =
N*dt ,where N=# of samples & dt=time between samples.
-
The fundamental freq. = f1 = 1/T. To avoid leakage we
will choose a frequency that is an integral multiple of f1.
-
The Nyquist frequency = Fn = 1/(2*dt) = (N*f1)/2. To
avoid aliasing, we will not go above this frequency. Remember that at least
two points per wave period are required for a frequency component to be
detected.
Part 1
-
Read the background information handout.
-
Change to your oc3150 directory and enter the MATLAB
environment.
-
Run FFTSPA by typing fftspa at the Matlab prompt.
-
Select the cosine wave.
-
The program will automatically choose 128 for N,
the number of points in the sample,
and 1 for dt, the sampling time step. We will use these values for
all plots and calculations in this lab.
-
Choose a signal frequency that is a multiple of f1.
For example type >> 2*f1 (instead of .015625)
-
Enter some wave amplitude, a mean value, and a phase shift.
-
The figure shows plots of several cycles of the signal as
well as its Fourier transform. Can you interpret the plot of the
spectrum (i.e. Fourier coefficients)?
-
Repeat the run for cosine waves of other frequencies.
Always choose an integral multiple of f1 and stay below the Nyquist frequency
(.5 Hz).
Part 2
Select the wave form that gives a combination of
sinusoids.(#2) The program will again set N = 128 and dt = 1. Stay within the frequency
constraints given above. You can now build an input signal by adding together
a number of sinusoids . Observe how the Fourier analysis detects the individual
frequencies. Save one plot to turn in with your report.
Part 3 - Aliasing
-
For each of the following frequencies, select the cosine wave as in Part 1.
Keep the amplitude and offset the same in parts a and b, and set
the phase shift to zero.
-
f = 60*f1 = .46875 = .5 - 4*f1.
-
f = 68*f1 = .53125 = .5 + 4*f1.
-
Note that the input signals and the spectra look the
same for both frequencies. The frequency which is 4*f1 beyond the nyquist
frequency of .5 is folded back into the spectrum and appears at
.5 - 4*f1.
-
Try 127*f1 = .5 + 63*f1, with other input values the same as
in Part 3, #1. The plot of the sampled signal
will look like a single cosine wave and the spectrum will show a single
component at the fundamental frequency of f1. The spectrum has folded all
the way back to f1. Print out this plot.
-
Repeat Part 3, #3 with a 90 degree phase shift (i.e., Enter
+90 to change cos(wt) to cos(wt - pi/2) ). Don't change
anything else from what you entered in #3. You might
expect that this would give a regular sine wave. Note, however, that in addition
to having a different frequency the resulting wave form
is inverted. This behavior occurs when an odd function, such as a sine
wave, is aliased. Also print out this plot for submission with your report.
Part 4 - Leakage
Select the cosine wave (N=128 and dt = 1). This time
choose a freq. that is not a multiple of f1, such as 3.5*f1 (Keep the freq.
< 64*f1 = .5 = Fnyquist). Set the offset to zero. Since the Fourier analysis
is a harmonic analysis, the single component's energy is divided between neighboring
frequencies (e.g., if f = 3.5*f1, most energy will be divided between
3*f1 and 4*f1). However, note that the spread of energy to neighboring harmonics
is far wider. This is caused by abruptly truncating the wave form.
The total variance of the wave should be approximately correct (Check this).
Again, you will need to save the plot for your report.
Ideally, for the single component wave
at f = 3.5*f1 you should be able to compute the total variance by summing
the squares of the expected amplitudes at 3*f1 and 4*f1 and dividing by
two. Here, because of leakage, the total variance must be calculated by
adding the
squares of the amplitudes from all the frequency components and dividing
by two.
Part 5 - Report
-
Turn in one plot from Part 2. Is the spectrum what you
expected to see? Explain. What is the expected variance?
-
Part 3, #1.a and 1.b: Why did the plots look like they did?
Determine the frequency of another simple cosine wave that
would yield a spectrum exactly like these two under this type of analysis.
Please explain your answers fully.
-
Turn in the plots from Part 3, #3 and #4.
Explain in detail why the sine wave in Part 3, #4 is inverted, but the cosine in
Part 3, #3 is not inverted.
Illustrate your explanation with two separate sketches of high frequency sinusoids
(one for #3 and one for #4)
on which you mark off the appropriate sampled points, starting with t=0.
Label your plots carefully to indicate how T for the sinusoid relates to the
sample spacing, dt. Show how each resultant signal resembles one of your
two plots from Part 3.
-
Turn in the plot obtained in Part 4. As suggested in the
second paragraph of Part 4, try computing the variance of your truncated data
set by using only the estimated amplitudes (heights) of the two tallest bars on your
spectrum histogram. Also
compute the variance based on your specified amplitude for the cosine wave. How
do these compare to the total variance computed by Matlab?