%Frequency f
f=fs/2*linspace(0,1,1024/2+1);
%Discrete Fourier Transform y
y=fft(data);
%Butterworth Filter with order 2, cuttoff Frequency 4500, sample frequency 11025
[B,A]=butter(2,5000/11025);
plot(f,2*abs(y(1:1024/2+1)))
filtdata=filtfilt(B,A,data);
z=fft(filtdata);
plot(f,2*abs(filtdata(1:1024/2+1)));
sound (filtdata)
Ah - now I can see the spectrum, low pass filtering makes sense
[I can't seem to download the .wav file though - no matter]
Aye, the Butterworth filter (with sufficiently high order and/or a low enough Fc) will do the job - the only problem is that it will also attenuate more of your desired signal spectrum than a sharper filter would (which may/may not be a problem, depending on what the desired signal spectrum is). Given there's only one narrowband tone though, I'd recommend a notch filter. Try:
filt = fdesign.notch('N,F0,BW', 10, 5000, 100, 11025); % 5 kHz notch, ~100Hz wide
filtData = filter(design(filt), data);
Let me know how it goes!
sound (data,fs)
f=fs/2*linspace(0,1,1024/2+1);
[B,A]=butter(2,(5000/11025));
filtdata=filtfilt(B,A,data);
sound(filtdata,fs)
filt = fdesign.notch('N,F0,BW', 10, 5000, 100, 11025);
filtdata1 = filter(design(filt), data);
sound (filtdata1,fs)
I'm not sure if I'm using the butterworth wrong, or if I'm using fft in the wrong places or what haha.
%Frequency f
f=fs/2*linspace(0,1,1024/2+1); ---> creates an array of frequencies (so the FFT result is more readable)
%Discrete Fourier Transform y
y=fft(data); ----> take "data" and figure out the frequency content, save it as "y"
%Butterworth Filter with order 2, cuttoff Frequency 4500, sample frequency 11025
[B,A]=butter(2,5000/11025); ---> generate filter coefficients for a Butterworth filter
plot(f,2*abs(y(1:1024/2+1))) ---> plot FFT output vs. the frequency bins (shows your signal spectrum)
filtdata=filtfilt(B,A,data); ---> use butterworth filter coefficients and applies the filter to "data", saves it into "filtdata"
z=fft(filtdata); ---> take "filtdata" and figure out the frequency content, save it as "z"
plot(f,2*abs(filtdata(1:1024/2+1))); ---> plot "filtdata" frequency content vs. frequency bins
sound (filtdata) --> play filtered sound file (filtdata)
[B,A]=butter(2,5000/11025); ---> generate filter coefficients for a Butterworth filter
filtdata=filtfilt(B,A,data); --> apply filter defined by coefficients in A and B
sound (filtdata) --> play filtered sound file (filtdata)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?