Aim
Generate a discrete-time sequence by sampling a continuous-time signal, and show that when the sampling rate is below the Nyquist rate, aliasing occurs when the signal is reconstructed.
Objectives
- State the sampling theorem and work out the Nyquist rate of a band-limited signal.
- Reconstruct a signal from its samples with ideal (sinc) interpolation.
- Predict the alias frequency fa = |f₀ − k·fs| and check it by seeing and hearing the result.
- Read the sampled spectrum as copies of the original spectrum repeated every fs.
Environment
MATLAB (signal created on a dense "continuous" grid, sampled with n/fs, and plotted with stem), or the virtual sampler on the Simulator tab. Use headphones at a low volume for the audio part.
Sampling
Sampling takes the values of x(t) at equally spaced times t = nTs: x[n] = x(nTs), where fs = 1/Ts. In the frequency domain, sampling makes copies of the spectrum at every multiple of fs:
Sampling theorem (Nyquist–Shannon)
A signal band-limited to fmax can be recovered exactly from its samples if
If fs < 2fmax, the spectral copies overlap. A high frequency then "folds back" and looks like a lower one:
Visual aid — the wagon-wheel effect
A movie camera samples a spinning wheel at a fixed frame rate. When the wheel turns more than half a revolution per frame, it seems to turn slowly, or even backwards. That is aliasing.
- In the Simulator, set the signal frequency f₀ = 500 Hz. The Nyquist rate is 1000 Hz.
- Set fs = 4000 Hz (well above Nyquist). The reconstruction (green) matches the original (blue). Press Play original and Play reconstructed; they sound the same.
- Lower fs slowly to 1200 Hz, then 1000 Hz, then 800 Hz. Watch the spectrum: the copies move toward each other and then overlap.
- At fs = 800 Hz, predict falias = |500 − 800| = 300 Hz. Check it on the plot and by ear.
- Press Record in Observations for at least 6 (f₀, fs) pairs, some above and some below Nyquist. For each one, count the cycles of the green curve in the window and type the frequency you measured.
- Edge case: fs = 2f₀ exactly with phase 90° (sine). Every sample is zero!
Pre-lab diagnostic
Signal & sampler
Aliasing table
Record the current setting, measure the frequency of the reconstructed (green) signal, and type it in.
Analysis
Post-lab quiz
Self-evaluation
exp3_sampling.m
%% Experiment 3: Sampling and aliasing clc; clear; close all; f0 = 500; % signal frequency (Hz) t = 0:1e-6:6e-3; % dense "continuous" time grid x = cos(2*pi*f0*t); for fs = [4000 1000 800] % above, at, and below Nyquist Ts = 1/fs; n = 0:floor(6e-3/Ts); xn = cos(2*pi*f0*n*Ts); % ideal sinc reconstruction xr = zeros(size(t)); for k = 1:length(n), xr = xr + xn(k)*sinc((t - n(k)*Ts)/Ts); end figure; plot(t,x,'b'); hold on; stem(n*Ts,xn,'r'); plot(t,xr,'g--'); fa = abs(f0 - fs*round(f0/fs)); title(sprintf('fs = %d Hz, alias = %g Hz',fs,fa)); legend('x(t)','x[n]','x_r(t)'); end % soundsc(cos(2*pi*f0*(0:1/8000:1)),8000) % listen