Electrical – MATLAB How to pass a signal into a low-pass filter in matlab

fourierlow passMATLAB

I'm having trouble figuring out how to pass a signal into a low pass filter using MATLAB.

I am given a .wav file and am following instructions on how to remove high frequency noise compenents from taking the Discrete Fourier Transform(DFT) of the audio signal. The idea is that there is a secret message in the .wav file that is currently being hidden by a lot of unwanted frequency noise. I am supposed to get rid of said noise.

My script is currently as follows:
[y, Fs] = audioread('horrible_noise.wav');
y = y(:.1);
plot(y)
NFFT = length(y);                             % number of discrete points
Y = fftshift(fft(y,NFFT));                               % DFT of the audio signal
F = ((-1:2/NFFT:1-2/NFFT)*Fs);                 % Range of the frequency of the audio file
magnitude_Y = abs(Y);                                % Magnitude of DFT
phase_Y = unwrap(angle(Y));                      % Phase of DFT

I'm supposed to plot the magnitude and phase and explain any trends in the plots.

plot(magnitude_Y,F)
plot(phase_Y,F)

At this point, I am supposed to remove the high-frequency components that are unwanted by setting them to zero. Which is apparently done via low-pass filtering. This is where I am having trouble. I have seeked help on this and came across commands such as using butter, fft, etc. I have no idea how to use those functions and don't even know if that is the right way of approaching my problem.

So again, I would like help on passing this signal(DFT) into a low-pass filter to get rid of unwanted noise. Thanks.

Audio signal in question – Warning, the sound isn't pleasant to listen to. Would recommend lowering your volume.

Best Answer

An FIR-filter with windowing would work well in this case. Refer to the following link to see how different orders of FIR filters (for low-pass, band-pass and high-pass) can be implemented: https://www.mathworks.com/help/signal/ref/fir1.html

The type and degree of windowing will also strongly impact the design of your low-pass filter: https://www.mathworks.com/help/signal/ug/windows.html