글

라벨이 fir filter인 게시물 표시

바로 프로젝트 적용 가능한 FIR Filter (low/high/band pass filter )를 c나 python으로 만들기

이미지
 band pass filter 코드가 필요해 인터넷을 검색을 해봤지만, 쓸 만한 코드와 자료가 별로 없어 그냥 만들어 쓰기로 했다. 필요한 공식은 위키피디아에 나와있다. https://en.wikipedia.org/wiki/Finite_impulse_response 1. filter 크기 FIR filter를 만들 때 filter의 크기(tpas의 크기)를 결정할 때 도움될 수식이 있다.   N=A㏈Fs / 22*Δf A㏈ : 감쇄될 db Fs : Sampling Frequency Δf : frequency bandwidth 출처 :  https://www.allaboutcircuits.com/technical-articles/design-of-fir-filters-design-octave-matlab/ def estimatefilterlen(fl,fh,fs,db):     N = int(np.round(db * fs / (22 * (fh-fl)))-1)     return N 2. Low Pass Filter [ python code ] def lowpassfilter(f,fs,N):     taps = np.zeros(N)          fc = f / fs     omega = 2*np.pi*fc     middle = int(N/2)     for i in range(N):         if i == middle:             taps[i] = 2*fc         else:    ...