Signal corrupted with AWGN
from pylab import show
import numpy as np
import matplotlib.pyplot as plt
fs = 4096 # sampling rate [Hz]
T = 4 # duration [s]
amp = 0.1 # amplitude of the sinusoid
ome = 13 # frequency of the signal
N = T*fs # total number of points
# time interval spaced with 1/fs
t = np.arange(0, T, 1./fs)
# white noise
noise = np.random.normal(size=t.shape)
# sinusoidal signal with amplitude amp
template = amp*np.sin(ome*2*np.pi*t)
# data: signal (template) with added noise
data = template + noise
plt.figure()
plt.plot(t, data, '-', color="grey")
plt.plot(t, template, '-', color="white", linewidth=2)
plt.xlim(0, T)
plt.xlabel('time')
plt.ylabel('data = signal + noise')
show()
Matched Filter
from numpy import ones,convolve as convol
from matplotlib.pyplot import plot,xlabel,ylabel,title,show
#Matched Filter Output
T =4#
a =2#
t = range(0,T+1)
g = [2*xx for xx in ones([1,T+1])][0]
h =[abs(x) for x in (convol(g,g))]
for i in range(0,len(h)):
if(h[i]<0.01):
h[i]=0
h = [hh-T for hh in h]
t1 = range(0,len(h))
plot(t,g)
xlabel('t--->')
ylabel('g(t)---->')
title('Rectangular pulse duration T = 4, a =2')
show()
plot(t1,h)
xlabel('t--->')
ylabel('Matched Filter output')
title('Output of filter matched to rectangular pulse g(t)')
show()
No comments:
Post a Comment