Matched filter

279 views (last 30 days)
vsee on 1 Apr 2011
How can I write a mtached filter in Matlab? I have the filter design and signal processing tool boxes.

Answers (5)

Honglei Chen
Honglei Chen on 1 Apr 2011
If you have a signal, x, then the matched filter's coefficients is given by time reverse of x, i.e., x(end:-1:1). If your signal is complex, you also need to to use complex conjugate. You can then use it just as an FIR filter. For example,
>> x = ones(10,1);
>> b = x(end:-1:1);
>> y = filter(b,1,x);
Mustahsan Ali Khan Khanzada Rajput
How to apply matched filter if the signal is complex?
Honglei Chen
Honglei Chen on 12 Jan 2017
It's the same, use the filter function. The only difference is when you come up with the filtering coefficient, you need to add a conjugate, like
b = conj(x(end:-1:1))

Sign in to comment.

Andrew Newell
Andrew Newell on 1 Apr 2011
Check out MATLAB Simulations for Radar Systems Design from the File Exchange.

Mathuranathan Viswanathan
Mathuranathan Viswanathan on 13 Apr 2013
Hi You can try the model given here
Regards Mathuranathan

Bhaskar on 15 Apr 2011
To elaborate on Honglei's answer. If the signal you are trying to design a matched filter for, is x, then --
>> b = x(end-1:1);
>> y = filter(b,1,x);
You should already have x.
  1 Comment
mmm ssss
mmm ssss on 9 Jan 2012
how can implement the same filter on image ?
how i should represent x.

Sign in to comment.

Nicole Bienert
Nicole Bienert on 7 Jan 2020
The built in xcorr function can be used - you just need to normalize by fs and square the output. See below for an ideallized example:
%Purpose: Demonstrate how to match filter correctly
fs = 50*BW; %sample rate
T= 1/fs; %sample period
fc = 330e6; %center freq
chirpLen=0.075; %chirp length
A=3; %amplitude of voltage signal (normally unknown)
Ar=2; %amplitude of reference voltage signal (normally unknown)
%create the signal withought noise and zero padded on either side (zero
%padding not necessary because xcorr does that, I'm just demonstrating that
%signals don't need to be the same length.)
%create the reference chirp
%normalize reference chirp: The reference chirp needs to have energy of 1
%so that it doesn't bias the output of the match filter. A filter shouldn't
%be applying gain to the signal or changing the units. The signal is in
%volts, so we divide by the square root of the energy to normalize it.
%If you know the signal's amplitude (for CW or FMCW):
%If you don't know the signal's amplitude, integrate to find energy (if it is noiseless):
% perform match filtering
[R,lags] = xcorr(sig,ref_chirp); %signals don't need to be the same length
%R is the sum of each data sample as the signals are shifted past
%eachother, so to make the numerical integration correct, you need to
%multiply by dx which is T in this case. Then to get the filtered voltage
%signal in units of energy, you need to square it.
R=(abs(R*T)).^2; %absolute value only necessary if signals are complex
% take only positive side
R = R(lags>=0);
xlim([index-250 index+250]*T)
display(['Energy in signal was: ',num2str(A.^2/2*chirpLen)])
display(['which is the same as the peak of the match filter: ',num2str(matchFiltPeak)])
Walter Roberson
Walter Roberson on 5 Jan 2022
code not working, t is undefined and later circular reference to refchirp
Charles Sutherland
Charles Sutherland on 23 Mar 2022
This worked for me:
and then move it to -
fs = 50*BW; %sample rate
T= 1/fs; %sample period
fc = 330e6; %center freq
chirpLen=0.075; %chirp length
A=3; %amplitude of voltage signal (normally unknown)
Ar=2; %amplitude of reference voltage signal (normally unknown)
Worked for me anyway...

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!