How to use a Fir1 filter to make a lowpass filter
Afficher commentaires plus anciens
Hi, I'm currently trying to make a lowpass filter for a sound clip with the specs of being order 128 and having a curoff frequency of 3575 Hz. Using the tf function does produce a graph, but that graph comes up as blank for any order greater than 70. People are recommending using a fir1, which, while it does produce a graph, though I'm unsure if these are correct given how I'm also getting the following error messages:
"Error using fir1>chkWindow (line 286)
Window length must be the same as the filter length.
Error in fir1>eFir1 (line 161)
wind = chkWindow(L,varargin{windIndex});
Error in fir1 (line 92)
[b,a] = eFir1(varargin{:});
Error in Lowpass (line 25)
blo = fir1(128,0.48,chebwin(35,30));"
My code is as follows:
audioread('beep.wav');
info = audioinfo('beep.wav')
filename = 'beep.wav';
audiowrite(filename,y,Fs);
[y,Fs] = audioread('beep.wav');
sound(y,Fs)
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
figure(1)
plot(t,y)
xlabel('Time')
ylabel('Audio Signal')
title 'Beep Signal'
filename = 'Beep.wav';
audiowrite(filename,y,Fs);
t = (0:length(y)-1)/Fs;
bhi = fir1(34,0.48,'low',chebwin(35,30));
freqz(bhi,1)
blo = fir1(128,0.48,chebwin(35,30));
outlo = filter(blo,1,y);
subplot(2,1,1)
plot(t,y)
title('Original Signal')
ys = ylim;
subplot(2,1,2)
plot(t,outlo)
title('Lowpass Filtered Signal')
xlabel('Time (s)')
ylim(ys)
Any help explaining what is going wrong with this code would be appreciated
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Digital Filter Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

