# writing matched filter to determine binary signal

102 views (last 30 days)
Jacob Shamir on 22 Aug 2020
Answered: Image Analyst on 25 Aug 2020
Hello evreyone,
I have a question.
I have a signal passing binary valeus in two wave forms like that:
I have the " T " definning the time value of one bit in the sampling, in the signal array (how many sampels it's the length of one bit) in my case: T = 10000.
I need to define from the given signal two matched filters (both liniar), one for logical '0' and the other for the logical '1'. I need to plot the impulse rsponse of the two filters.
I also need to transfer the signal through both fillters and plot the output.
It's importent to mention that I am not alowed to use built in function of matlab.
for example:
Thank you.

Devineni Aslesha on 25 Aug 2020
Hi Jacob,
Assuming that you do not want to use the inbuilt command for matched filter, here is the way to create signals, find the impulse response and get the signal output after passing through the matched filter.
% Input signal x(t)
rect1 = @(x,a) ones(1,numel(x)).*(abs(x)<a); % a is the width of the pulse
rect2 = @(x,a) -ones(1,numel(x)).*(abs(x)<a); % a is the width of the pulse
x = 1:1:1e4;
y1 = rect1(x,1e4);
y2 = rect2(x,1e4);
% Backward signal y1(-t), y2(-t)
newX = -1e4:1:-1;
newY1 = rect1(newX,1e4);
newY2 = rect2(newX,1e4);
figure(1)
subplot(2,1,1);
plot(x,y1,'c');
hold on;
plot(newX,newY1,'m');
subplot(2,1,2);
plot(x,y2,'c');
hold on;
plot(newX,newY2,'m');
% Impulse Response of matched filter y1(T-t)
% Shift the newY1 and newY2 to get the impulse response of y1 and y2
% Signal output after passing through the matched filter
% Convolute the shifted signal and y1 to get the filter output using conv. Similarly for y2.

Image Analyst on 25 Aug 2020
You can use strfind(), even though they're numbers, not strings. Attach your data if you need more help.

### Community Treasure Hunt

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

Start Hunting!