blob: c67d857cb91fd083d3c23c11b9b96ae22a4a20be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 27 16:05:59 2021
@author: sarah
"""
import numpy as np
import matplotlib.pyplot as plt
delay = 6.37
ampl = 1
print(f"Tap with amplitude={ampl}, delay={delay}")
order = 2 * np.floor(delay) + 1 #N
print(f"Creating filter of order N={order}")
samples = np.arange(0, order +1)
h = ampl*(np.sinc(samples-delay)) #sinc
# plt.stem(samples, h)
# plt.show()
t = np.arange(50)
signal = np.sin(2 * np.pi * t * 0.05)
signal_shifted = np.convolve(h, signal, mode='full')
#Time PLot
# plt.xlabel('Delay')
# plt.ylabel('Amplitude')
# #plt.title('')
# plt.plot(t, signal)
# plt.grid(True)
# plt.show()
# plt.plot(signal_shifted)
t1 =np.arange(0.0,order, 0.01)
plt.grid(True)
plt.stem(samples, h,linefmt='C0-')
plt.plot(t1,np.sinc(t1-delay),'b--')
plt.xlabel('Delay')
plt.ylabel('Amplitude')
plt.show()
|