Matched filter
이전 댓글 표시
How can I write a mtached filter in Matlab? I have the filter design and signal processing tool boxes.
답변 (5개)
Honglei Chen
2011년 4월 1일
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);
댓글 수: 5
vsee
2011년 4월 1일
Honglei Chen
2011년 4월 4일
I was just giving an example. x and b are the same because x happens to be the same as its time inverse. You can replace x with a vector representing your particular signal. The key here is "end:-1:1" which flips the signal. You can also use flipud or fliplr depending on your vector's orientation.
Nuzat Alam
2013년 4월 3일
Hii i was wondering what is the impulse response of matched filter here?I think it is related to b. Do you think if i want to select a specific sample number for b, i also need to change the length of input signal x?
Mustahsan Ali Khan Khanzada Rajput
2017년 1월 12일
How to apply matched filter if the signal is complex?
Honglei Chen
2017년 1월 12일
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))
HTH
Andrew Newell
2011년 4월 1일
1 개 추천
Mathuranathan Viswanathan
2013년 4월 13일
1 개 추천
Hi You can try the model given here
Square Root raised Cosine - Matched filter implementation http://www.gaussianwaves.com/2011/04/square-root-raised-cosine-filter-matchedsplit-filter-implementation-2/
Regards Mathuranathan
Nicole Bienert
2020년 1월 7일
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
BW=3.84e6;
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.)
sig=[zeros(1,ceil(chirpLen*fs)),A*chirp(t,0,t(end),BW),zeros(1,ceil(chirpLen*fs))];
%create the reference chirp
ref_chirp=Ar*chirp(t,0,t(end),BW);
t=[0:T:(length(ref_chirp)-1)*T];
%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):
energy=Ar^2/2*chirpLen;
%If you don't know the signal's amplitude, integrate to find energy (if it is noiseless):
%energy=trapz(t,ref_chirp.^2)
ref_chirp=ref_chirp/sqrt(energy);
% 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);
lags=lags(lags>=0);
[matchFiltPeak,index]=max(R);
figure()
plot(lags*T,R)
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)])
댓글 수: 7
Andreas Blom
2020년 3월 11일
I tried running this code but cant. Unrecognized function or variable 't'.
NoYeah
2020년 4월 27일
you may missed below line
t=[0:T:(length(ref_chirp)-1)*T];
Anastasia Kov
2020년 4월 27일
I faced the same code error as Andreas talking about.
I guess, the issue is here:
ref_chirp=Ar*chirp(t,0,t(end),BW);
t=[0:T:(length(ref_chirp)-1)*T];
"ref_chirp" referes to "t" and vise versa.
There must be some additional definition for "ref_chirp" or "t", isn't it?
Anastasia Kov
2020년 4월 27일
As well as I do not understand this line:
R=(abs(R*T)).^2; %absolute value only necessary if signals are complex
It will not work unfortunately, R is not defined.
Could somebody help please?
Would be very usefull to have this code working.
Thank you!
MUKESH KUMAR
2020년 6월 3일
Walter Roberson
2022년 1월 5일
code not working, t is undefined and later circular reference to refchirp
Charles Sutherland
2022년 3월 23일
This worked for me:
Change
t=[0:T:(length(ref_chirp)-1)*T];
to
t=[0:T:((chirpLen*fs)-1)*T];
and then move it to -
BW=3.84e6;
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)
t=[0:T:((chirpLen*fs)-1)*T];
Worked for me anyway...
Cheers
카테고리
도움말 센터 및 File Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!