I need to study a wave file for every 100 Hz. However, I dont know how can I design filer for each 100 Hz. Let's say 0-100 Hz, 100-200 Hz, ... , ((fs/2)-100) _ (fs/2) Hz.

Is it any MATLAB code for it ? How many samples are needed for bandwidth of 100 Hz ? I maen how should calculate it ? Please guide me. Thanks.


A windowed FFT with a length that corresponds to 2/100ths of a second will give you overlapping filters each with roughly 100 Hz bandwidth. Just use every other FFT result bin if you want 100 Hz filter spacing. The window shape (Von Hann, Nutall, etc.) will allow some tuning of the filter shape, but the main passband lobe of a windowed FFT will be about twice the FFT bin spacing in width.

An unwindowed FFT creates filters with too much stop band ripple to usually be considered useful.

You can also zero-pad and/or use an FFT a higher integer multiple of 0.01S in length to get better control over the windowing (a proportionately wider or narrower Gaussian window, for instance) and the window's frequency response.

The number of samples needed will be the FFT length in samples, or the sample rate multiplied by the FFT's length in time.


I have assumed your sampling rate as 1KHz & designed the code. The minimum sampling frequency is the nyquist frequency ofcourse. That depends on your design input.

fs=1000; % sampling freq
fc=99/2; % cutoff freq for filter  
fc1=101/2; % cutoff freq for filter
LpfLength=96; % Number of Filter coefficients
% Low Pass Filter
lpf=fir2(LpfLength-1,[0 fc fc1 fs/2]/(fs/2),[1 1 0 0]);
for n=1:LpfLength,
for q=2:(fs/100)+1,
    for n=1:LpfLength,

FFThn=fft(lpf(1,:),NFFT);    %enter any value between 1 & fs/100 in place of 1 for different bpf
magfhn=20*log10(abs(FFThn));    % Magnitude in dB

plot((0:NFFT-1)*fs/NFFT,magfhn); %Freq. plot of LPF
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('Low Pass Prototype Filter')
axis([0 fs -100 5]);

The variable lpf will hold different band pass filters in different rows. You can use those.

  • $\begingroup$ Thanks for respond. How can I find the number of samples for each filter ? is it any formula for it ? I mean is it any relation between bandwidth of the filter like 100 Hz with number of samples for filter? $\endgroup$ – Ali Bodaghi Mar 29 '14 at 9:05
  • $\begingroup$ I cant understand what u mean by number of samples for a filter. If u mean the no. of coefficients of the filter, which in above example is 96, than that depends on how sharp a filter u want. If u replace 96 with 24, then the roll-off of the filter will be less steep & the -3dB passband will be >100. While if u replace 96 with 192, then the filter will be sharper with steep roll-off with passband = 100. More the coefficients, more the computation. I dont think there is a precise formula for it $\endgroup$ – KharoBangdo Mar 29 '14 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.