Lab: Properties of the Fourier Transform — MATLAB
Objective
Verify and visualize core properties of the Fourier transform using MATLAB. Students will generate signals,
compute FFTs, and compare analytical expectations with numerical results.
Prerequisites
Basic MATLAB familiarity, signals & systems theory, knowledge of sampling (fs, dt), and plotting in MATLAB.
How to run the included MATLAB scripts
1. Copy each code block into a separate .m file or run sections in the MATLAB editor. 2. Ensure the sampling frequency (fs) and
time vector (t) are set consistently. 3. Use fftshift to center the zero-frequency component when plotting. 4. Save generated plots
as images and paste them into the 'Results & Observations' sections in this PDF.
Notes on FFT normalization and frequency axis
When using MATLAB's fft, remember to scale frequency axis using sampling frequency fs and normalize amplitude
when comparing with continuous-time Fourier transform. Example frequency axis:
N = length(x);
df = fs/N;
f = (-N/2:N/2-1)*df;
% frequency vector in Hz (centered)
X = fftshift(fft(x));
% To approximate continuous FT magnitude: abs(X)*dt
1. Linearity Property
Theory: a*x1(t) + b*x2(t) a*X1(f) + b*X2(f)
% Linearity test - MATLAB
fs = 100; dt = 1/fs; t = -5:dt:5-dt;
x1 = rectpuls(t,2);
% rectangle
x2 = sinc(t);
% sinc (MATLAB's sinc is sin(pi*x)/(pi*x))
a = 2; b = -1;
x = a*x1 + b*x2;
N = length(t); df = fs/N; f = (-N/2:N/2-1)*df;
X1 = fftshift(fft(x1))*dt;
X2 = fftshift(fft(x2))*dt;
X = fftshift(fft(x))*dt;
% Compare: a*X1 + b*X2 vs X
disp(max(abs(X - (a*X1 + b*X2))));
% should be near numerical precision
figure;
subplot(3,1,1); plot(f,abs(X1)); title('|X1(f)|'); xlabel('Hz');
subplot(3,1,2); plot(f,abs(X2)); title('|X2(f)|');
subplot(3,1,3); plot(f,abs(X),f,abs(a*X1 + b*X2)); legend('X','aX1+bX2');
2. Time Shifting Property
Theory: x(t - t0) exp(-j*2*pi*f*t0) * X(f)
% Time shift test
t0 = 1.5;
% shift in seconds
shift_samples = round(t0/dt);
x_shift = circshift(x1, shift_samples);
% circular shift approximates time shift for finite-length sampled signal
X_shift = fftshift(fft(x_shift))*dt;
% Multiply original X by phase term
phase = exp(-1j*2*pi*f*t0);
X_expected = X1 .* phase;
disp(max(abs(X_shift - X_expected))); % small difference due to sampling and circular shift
figure;
subplot(2,1,1); plot(t, x1, t, x_shift); legend('x1','x1 shifted'); xlabel('s');
subplot(2,1,2); plot(f,angle(X1),f,angle(X_shift)); legend('angle X1','angle Xshift');
3. Frequency Shifting (Modulation) Property
Theory: x(t) * exp(j*2*pi*f0*t) X(f - f0)
% Frequency shift (modulation)
f0 = 10; % Hz
x_mod = x1 .* exp(1j*2*pi*f0*t);
X_mod = fftshift(fft(x_mod))*dt;
% Compare by shifting frequency axis
figure;
subplot(2,1,1); plot(t, real(x_mod)); title('Real part of modulated x(t)');
subplot(2,1,2); plot(f, abs(X_mod)); title('|X_mod(f)| - should match |X1(f-f0)|');
4. Time Scaling Property
Theory: x(a t) (1/|a|) X(f / a)
% Time-scaling test
a = 2;
% compression factor >1 compresses in time
t_scaled = t * a;
x_scaled = rectpuls(t_scaled, 2);
% width scaled accordingly
X_scaled = fftshift(fft(x_scaled))*dt;
% To compare: scale frequency axis and amplitude
f_scaled = f / a;
X1_interp = interp1(f, X1, f_scaled, 'linear', 0);
% interpolated
figure;
subplot(2,1,1); plot(t, x1, t, x_scaled); legend('x1','x_scaled');
subplot(2,1,2); plot(f, abs(X1), f, abs((1/abs(a))*X1_interp)); legend('|X1|','(1/|a|)X(f/a)');
5. Convolution Property
Theory: x1(t) * x2(t) X1(f) · X2(f)
% Convolution test
x_conv = conv(x1, x2, 'same')*dt;
X_conv = fftshift(fft(x_conv))*dt;
X_product = X1 .* X2;
% conv in time (note dt scaling)
disp(max(abs(X_conv - X_product)));
% check numerical similarity
figure;
subplot(2,1,1); plot(t, real(x_conv)); title('x1 * x2');
subplot(2,1,2); plot(f, abs(X_conv), f, abs(X_product)); legend('FFT(conv)','X1.*X2');
Parseval's Theorem (Energy)
Theory: |x(t)|^2 dt = |X(f)|^2 df (use dt and df scaling for discrete FFT approximation)
% Parseval check
energy_time = sum(abs(x).^2) * dt;
energy_freq = sum(abs(fft(x)).^2) * (1/N) * dt;
% equivalent scaling; several equivalent forms exist depending on
% Simpler commonly used (with fftshift and dt,df):
X = fftshift(fft(x))*dt;
energy_freq2 = sum(abs(X).^2) * df;
disp([energy_time, energy_freq2]);
Duality
Theory (informal): If x(t) X(f), then X(t) x(-f) (up to scaling and conventions). Use examples cautiously for
discrete numerics.
% Duality - illustrative only
% Example: triangular pulse FT is sinc^2; swapping roles illustrates duality properties but numerical checks requir
Student Results & Observations (Template)
For each section below: paste figures (exported from MATLAB) and answer the observation questions.
Section
Space for student to paste plots and write observations
1. Linearity
Plot area:
Observations:
Conclusion:
2. Time Shift
Plot area:
Observations:
Conclusion:
3. Frequency Shift
Plot area:
Observations:
Conclusion:
4. Time Scaling
Plot area:
Observations:
Conclusion:
5. Convolution
Plot area:
Observations:
Conclusion:
Parseval
Plot area:
Energy(time):
Comment:
Duality
Energy(freq):
Plot area:
Observations:
Common Pitfalls & Tips
- Remember to include dt when comparing amplitudes between time and frequency domains. - Use sufficiently long time
windows and sampling rates to avoid aliasing. - Using circshift approximates time shift but introduces wrap-around; zero-padding
is often better. - Interpolation is needed when comparing scaled frequency spectra.
References & Further Reading
Suggested textbooks: Oppenheim & Willsky 'Signals & Systems', Proakis 'Digital Signal Processing'. MATLAB
documentation: fft, fftshift, interp1, conv, rectpuls, sinc.