Programming lesson
MATLAB Communication Systems Lab: Modeling Noise and Filtering for Digital Signals
A comprehensive tutorial on modeling thermal noise in binary transmission, computing information rate and bit error probability, and implementing digital filters (median, FFT, Butterworth) in MATLAB for communications systems labs.
Introduction to Communications Systems Lab 4
In this tutorial, we build on the concepts from Lab 3 to tackle the design tasks in Communications Systems Lab Script 4. You will model a binary signal over a twisted pair with thermal noise, analyze the impact of temperature and bandwidth on information rate and bit error probability, and implement filters to recover a message from noisy amplitude-modulated signals. By the end, you'll have a MATLAB routine that demonstrates practical trade-offs—just like tuning a gaming headset for clear audio or optimizing a streaming app's bitrate for a stable connection.
Understanding the Binary Signal Model
A binary signal uses +1 V for binary 1 and –1 V for binary 0, transmitted over a copper twisted pair. Thermal noise is modeled as additive white Gaussian noise (AWGN) with zero mean and variance proportional to temperature and bandwidth. The signal power is P = 1 W (since voltage=1 V into 1 Ω). The noise power is N = k * T * B, where k = 1.38e-23 J/K is Boltzmann's constant, T is temperature in Kelvin, and B is bandwidth in Hz.
Part A: Information Rate and Bit Error Probability
The maximum information rate (channel capacity) is given by the Shannon-Hartley theorem: C = B * log2(1 + P/N). The bit error probability for antipodal signaling in AWGN is Pe = 0.5 * erfc(sqrt(Eb/N0)), where Eb = P/Rb and N0 = k*T. For simplicity, assume Rb = B (Nyquist rate).
MATLAB Routine for Part A
Create a function lab4_partA that accepts signal power, bandwidth, and temperature as inputs. It computes and plots:
- Channel capacity vs. temperature for three bandwidths: fixed (1 kHz), increased (2 kHz), decreased (500 Hz).
- Bit error probability vs. temperature for the same bandwidths.
function lab4_partA(P, B, T_range)
% P: signal power (W), B: bandwidth (Hz), T_range: vector of temperatures (K)
k = 1.38e-23;
N = k * T_range * B;
C = B * log2(1 + P./N);
Eb = P / B; % assuming Rb = B
N0 = k * T_range;
Pe = 0.5 * erfc(sqrt(Eb./N0));
figure;
subplot(2,1,1); plot(T_range, C); xlabel('Temperature (K)'); ylabel('Capacity (bps)');
subplot(2,1,2); semilogy(T_range, Pe); xlabel('Temperature (K)'); ylabel('Bit Error Probability');
endRecommendation
For a practical system, choose a temperature near 300 K (room temperature), bandwidth around 1 kHz, and signal power 1 W. This yields low bit error probability (≈10^-12) and reasonable capacity (≈10 kbps). Avoid extreme temperatures like 5500 K (Sun's surface) as noise would dominate.
Part B: Signal-to-Noise Ratio vs. Distance
Assume attenuation of 2 dB per km. The received signal power decreases with distance: P_r = P * 10^(-2*d/10). Noise power remains N = k*T*B. Compute SNR in dB: SNR_dB = 10*log10(P_r/N). Plot SNR vs. distance for your chosen operating characteristics.
function lab4_partB(P, B, T, d_max)
k = 1.38e-23;
d = 0:0.1:d_max;
P_r = P * 10.^(-2*d/10);
N = k * T * B;
SNR_dB = 10*log10(P_r/N);
plot(d, SNR_dB); xlabel('Distance (km)'); ylabel('SNR (dB)');
endQuestion 2: Digital Amplitude Modulation and Filtering
Starting from Lab 3's AM code, generate a carrier sine wave, a binary message, modulate, add AWGN, then decode using filters. Vary noise amplitude and filter length.
Moving Median Filter
Implement a moving median filter with variable window length. Test lengths from 3 to 21 samples. The optimum length balances noise removal and preserving signal edges—similar to smoothing a game controller's joystick input.
y_filtered = medfilt1(y_noisy, window_length);Frequency Domain Filter (FFT)
Use FFT to convert to frequency domain, zero out frequencies above the message bandwidth (e.g., 100 Hz), then inverse FFT.
Y = fft(y_noisy);
f = (0:length(Y)-1)*Fs/length(Y);
Y(abs(f) > 100) = 0;
y_filtered = ifft(Y, 'symmetric');Butterworth and Chebyshev Filters
Design low-pass filters using butter and cheby1 with cutoff frequency matching the message bandwidth.
[b,a] = butter(4, 100/(Fs/2), 'low');
y_filtered = filter(b, a, y_noisy);Comparison and Recommendation
Compare filters by computing mean squared error between filtered signal and original message. The moving median filter with window length ~11 often gives the best balance for binary signals, as it preserves edges while removing impulsive noise. The Butterworth filter provides smooth output but may smear edges. The FFT filter works well if noise is outside the message band.
Conclusion
This lab reinforces key communications concepts: noise modeling, capacity limits, and filter design. By varying parameters, you learn how temperature, bandwidth, and filter choice affect system performance—knowledge directly applicable to optimizing Wi-Fi, 5G, or even audio streaming apps. Submit your well-commented .m files with plots and reasoning.