Matched Filter: Theory and MATLAB Example
A matched filter is a linear filter designed to maximize the signal-to-noise ratio (SNR) for detecting a known signal in the presence of additive noise. It is widely used in communications, radar, and sonar.
1. Definition
If the known signal is s(t) with duration T, the impulse response of the matched filter is:
h(t) = s*(T - t)
In discrete time, for a signal s[n] of length N:
h[n] = s*[N-1-n]
2. Example: Rectangular Pulse
Consider a simple rectangular pulse:
s(t) = {
1, 0 ≤ t ≤ 2
0, elsewhere
}
Matched filter:
h(t) = s(2 - t)
s(t): ┌───────┐
| |
───────────┘ └────────
0 2
h(t): ┌───────┐
| |
───────────-------- |
0 2
3. MATLAB Simulation Example
We can implement a simple matched filter in MATLAB using a rectangular pulse:
% MATLAB Code: Matched Filter Example
% Parameters
T = 2;
Fs = 100;
t = 0:1/Fs:T-1/Fs;
s = ones(1,length(t));
noise = 0.5*randn(size(s));
r = s + noise;
h = fliplr(s);
y = conv(r,h);
t_y = 0:1/Fs:(length(y)-1)/Fs;
figure;
subplot(3,1,1);
plot(t,s,'LineWidth',2);
title('Transmitted Signal s(t)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t,r,'LineWidth',1.5);
title('Received Signal r(t) = s(t) + Noise');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t_y,y,'LineWidth',2);
title('Matched Filter Output y(t)');
xlabel('Time (s)');
ylabel('Amplitude');
Explanation:
sis the known transmitted pulse.ris the received signal corrupted by Gaussian noise.his the matched filter (time-reversed pulse).yis the convolution output showing a peak at the point of maximum alignment, which corresponds to the detection instant.
The peak of y(t) corresponds to the maximum correlation between the received signal and the known pulse, demonstrating the matched filter's ability to detect the signal in noise.
Peak Location of the Matched Filter Output
The peak of the matched filter output does not necessarily occur at the midpoint of the pulse. It occurs at the end of the pulse duration (t = T), which is the point where the entire pulse has “slid” across the filter.
1. Why the peak is at t = T
Matched filter:
h(t) = s(T - t)
Output:
y(t) = ∫₀แต r(ฯ) · h(t - ฯ) dฯ
- At t = 0 → small overlap → small output
- As t increases → overlap increases → output grows
- At t = T → full alignment → maximum output
2. Example with numbers
Pulse s[n] = [1, 2, 3], duration T = 3 samples
Matched filter h[n] = [3, 2, 1]
Convolution output y[n] = s[n] * h[n] = [3, 8, 14, 8, 3]
- n = 0 → small
- n = 1 → larger
- n = 2 → peak
- n > 2 → output decreases
Peak occurs where the full pulse aligns with the filter, not at the midpoint.
4. Summary
Matched filters leverage the known structure of a signal to produce a maximum output at the detection instant, allowing reliable detection even in the presence of noise. The impulse response is always the time-reversed and conjugated version of the transmitted signal. MATLAB simulation confirms that the filter output peaks exactly when the received pulse is aligned with the filter.
If you want, I can draw a tiny diagram showing the sliding pulse and peak at t = T — it really helps people see why it’s the end of the pulse, not the middle, that matters.