Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Matlab Code for Match filtering.

________________________________________________________________

clc;
clear all;
close all;
%=======================================================%
%Matched Filter%
%=======================================================%
A=input('Enter amplitude value= ');
r=input('enter input signal having length equal to 10');
%=======================================================%
%Analog Matched Filter%
%=======================================================%
s1=[0];
T=1:10;
s1=A*T;
s1=[s1 0 0 0]
h=0;
n=10
for t=1:10
h(n)=s1(t+A)
n=n-1
end
%=======================================================%
%Sampled matched Filter%
%=======================================================%
q=-max(T-A):-min(T-A);
s2=-A*T;
s2=[s2 0 0 0]
n=10;
for t=1:10
h2(n)=s2(t);
n=n-1;

end
%=======================================================%
%Analog Matched Filter Plotting%
%=======================================================%
figure(1)
subplot(3,1,1)
plot(s1,'r','linewidth',2)
title('Signal','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
subplot(3,1,2)
plot(h,'r:','linewidth',2)
title('impulse response or mirror image','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
y1=conv(s1,r)
subplot(3,1,3)
plot(y1,'r','linewidth',2)
title('Convolved output','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
axis tight;
%=======================================================%
%Sampled Matched Filter Plotting%
%=======================================================%
y2=conv(s2,r)
figure(2)
subplot(2,1,1)
plot(q,h,'r-.','linewidth',2)
grid on;
subplot(2,1,2)

plot(s2,'m:','linewidth',2)
title('Signal','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
axis tight;
figure(3)
subplot(2,1,1)
plot(h2,'r:','linewidth',2)
title('impulse response or mirror image','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
subplot(2,1,2)
stem(y2,'linewidth',2)
title('Convolved output','fontsize',12)
xlabel('time\rightarrow')
ylabel('Amplitude\rightarrow')
grid on;
axis tight;

________________________________________________________________

You might also like