MATLAB: How can I use bandpass filter on a .wav file

bandpass

Hi, In a project, I am asked to just consider frequency components between 250 HZ and 6000 HZ of a wav file. I tried to use a fir filter as I wrote below but it gave an error. Is there any way to solve this error or is there any different method to just take those frequencies?
if true
% code
N = 32;
fc1 = 250;
fc2 = 6000;
B = fir1(N, [fc1 fc2], 'bandpass');
end
Error is : Error using FIR1 Expected Wn to be an array with all of the values < 1.

Best Answer

‘Error using FIR1 Expected Wn to be an array with all of the values < 1.’
The audioread function will return the sampling frequency, ‘Fs’, necessary for you to design your filter.
Try this:
[y,Fs] = audioread(filename)'
Fn = Fs/2; % Nyquist Frequency
fc1 = 250/Fn; % Normalised Frequency

fc2 = 6000/Fn; % Normalised Frequency
Note that ‘Fs’ has to be greater than 12100 for your filter to work well.
I leave the rest to you.