-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fourier.py
27 lines (25 loc) · 890 Bytes
/
Fourier.py
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
import numpy as np
def DTFT(x, n, range, num):
# x and n are representation of signal in time domain
# range = [lbw, rbw] of w (omega)
# num is number of equispaced points from lbw to rbw
lbw = range[0]
rbw = range[1]
stepw = (rbw - lbw)/(num - 1)
w = np.arange(lbw, rbw+stepw, stepw)
X = x * np.exp(1j * n.T * w)
return X, w
def FreqRespDE(x_coeff, y_coeff, range, num):
# Frequency Response from Difference Equation
# range = [lbw, rbw] of w (omega)
# num is number of equispaced points from lbw to rbw
lbw = range[0]
rbw = range[1]
stepw = (rbw - lbw)/(num - 1)
w = np.arange(lbr, rbw+stepw, stepw)
m = np.arange(0, x_coeff.size-1, 1)
l = np.arange(0, y_coeff.size-1, 1)
numerator = x_coeff * np.exp(1j * m.T * w)
denominator = y_coeff * np.exp(1j * l.T * w)
H = numerator/denominator
return H, w