def fir1(n, wn):
# Variables definition :
nbands = len(wn) + 1
ff = np.array((0, wn[0], wn[0], wn[1], wn[1], 1))
f0 = np.mean(ff[2:4])
l = n + 1
mags = np.array(range(nbands)) % 2
aa = np.ravel(np.matlib.repmat(mags, 2, 1), order='F')
# Get filter coefficients :
h = firls(l - 1, ff, aa)
# Apply a window to coefficients :
wind = np.hamming(l)
b = np.matrix(h.T * wind)
c = np.matrix(np.exp(-1j * 2 * np.pi * (f0 / 2) * np.array(range(l))))
b = b / abs(c * b.T)
return np.squeeze(np.array(b)), 1
评论列表
文章目录