How to create a band pass filter

조회 수: 3 (최근 30일)
Anastasiya Kobrina
Anastasiya Kobrina 2015년 5월 4일
답변: Jeremy 2015년 6월 18일
Hi guys,
I would like to pass my .wav file through a band pass filter. I am not sure what order to use. To give an example- my .wav file contains USVs- aka my band is actually from 20 khz to 100 khz (beyond human hearing).
Sampling frequency is 50 kHz
fs = 50e3;
t = linspace(0,1,50e3);
% 1 kHz and 3 kHz sine waves
x = cos(2*pi*1e3*t)+0.5*sin(2*pi*3e3*t)+randn(size(t));
% Lowpass filter everything below 20 kHz
% Specify the filter
hlpf = fdesign.lowpass('Fp,Fst,Ap,Ast',20e3,20.1e3,0.5,50,50e3);
% Design the filter
D = design(hlpf);
% apply the filter
y = filter(D,x);
subplot(211)
plot(t(1:1000),x(1:1000)); title('Original Waveform');
subplot(212)
plot(t(1:1000),y(388:1000+387)); title('Filtered Waveform');
figure;
subplot(211)
plot(psd(spectrum.periodogram,x,'Fs',fs,'NFFT',length(x)));
title('Original Signal PSD');
subplot(212);
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(x)));
title('Filtered Signal PSD');

채택된 답변

Jeremy
Jeremy 2015년 6월 18일
you discuss a bandpass filter but you are applying a lowpass filter...
Aside from that, the order really depends on what type of data you have and what you are trying to accomplish, I know this doesn't really help. But you basically want to minimize the filter order that will meet your requirements. The higher the order, the higher the ripple and phase shift, so start low.
You are using a filter definition that defines the requirements and the filter order will be a result of those requirements. With Fp and Fst so close this will be a very high order filter.
You are also not specifying the design method, equiripple will be the default.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by