Matched filtering syntax problem

4 views (last 30 days)
Hana
Hana on 21 Mar 2014
Commented: Honglei Chen on 24 Mar 2014
Hello, i am trying to apply a Matchedfilter on a chirp signal on Matlab, and since im a beginner i couldnt solve the problem i had with this syntax. Can anyone help me plz?
t=0:0.001:2;
y= chirp(t,19,10,24);
x= step(y);
z= phased.MatchedFilter('filter',getMatchedFilter(y));
a= step(z,x);
plot(a);

Accepted Answer

Honglei Chen
Honglei Chen on 24 Mar 2014
You are mixing several things here. y in your script is a signal vector, not a waveform, so it does not work with the step() method.
You can do either
t=0:0.001:2;
y= chirp(t,19,10,24);
a= filter(fliplr(y),1,y);
plot(a);
or
t=0:0.001:2;
y= chirp(t,19,10,24);
myFilter = phased.MatchedFilter('Coefficients',flipud(y(:)));
a= step(myFilter,y(:));
plot(real(a));
Note that MatchedFilter handles complex signal and assumes each column as a channel. It also handles the state in case you want to stream the filtering operation.
HTH
  2 Comments
Hana
Hana on 24 Mar 2014
Thank you Honglei. I tried this script (matched filtering+ cross correlation)
t=0:0.1:10;
y= chirp(t,19,10,40);
k=awgn(y,10);
a= filter(fliplr(y),1,y);
subplot(4,1,1);
plot(y);
subplot(4,1,2);
plot(a);
s= xcorr(y,y);
subplot(4,1,3);
plot(s);
but im not sure of what i got here, the matched filter signal doesnt look right.
Honglei Chen
Honglei Chen on 24 Mar 2014
These are just matched filter results. In this case, filter and xcorr does essentially the same thing. However, note that the horizontal axes are different. For xcorr, it outputs all lags, from -(N-1) to (N-1), where N is the length of the input signal. That's why you see the peak at the middle. On the other hand, filter only outputs N samples so you see the peak, at the end. The result of filter is basically the first half of the result using xcorr. You could argue that xcorr result is more intuitive but in real applications input and output are often the same length so filter makes more sense there. If you want to see the rest, just pass in another zero frame, you'll see the rest, e.g.,
a = filter(fliplr(y),1,y);
a1 = filter(fliplr(y),1,zeros(size(y)));
HTH

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!