load handel; %Load an audio signal built into MATLAB %Array y contains the data. Fs equals the number of samples per second, %usually 8192. n = length(y); plot((1:n)/Fs,y) xlabel('Time (s)') ylabel('Amplitude') sound(y) %Play the audio signal z = fft(y); m=(n-1)/2; z_half = z(1:m+1); figure plot(Fs*(0:m)/n,abs(z_half)) xlabel('Frequency (Hz)') ylabel('Amplitude') f_cutoff = 2500; %Hz z_half(round(n*f_cutoff/Fs):end) = 0; %This zeros out the coefficients of terms corresponding %to frequencies of f_cutoff Hz or more. figure plot(Fs*(0:m)/n,abs(z_half)) xlabel('Frequency (Hz)') ylabel('Amplitude') pause z2 = [z_half; conj(z_half(end:-1:2))]; %Reconstruct the full fft y2=ifft(z2); %ifft is the inverse fft algorithm sound(y2) %Play the filtered audio signal