Lowpass filter frequency response has different –3 dB point after IFFT and FFT

Hello,
I would like to convert various frequency responses into WAV files to be used in Pure Data for convolution with music WAV files. Below, as an example, I am using a 4th-order lowpass filter with a –3 dB point at 1 kHz. The filter's frequency range is between 10 Hz and 22.05 kHz using 4,096 points which are linearly spaced. The upper frequency limit was chosen to be 22.05 kHz because the sampling frequency was assumed to be 44.1 kHz (i.e., double the Nyquist frequency).
My problem is where after performing an IFFT followed by an FFT, the –3 dB point has shifted from 1 kHz to around 2 kHz. Could someone please tell me whether my assumptions, code, or both are incorrect? Thank you very much in advance.
Fs = 44100; % Sampling frequency.
% Read in lowpass filter frequency response.
lpfY = readtable('LPF_lin.txt', 'HeaderLines', 11);
lpfY.Properties.VariableNames = {'freq', 'level', 'phase'};
% Plot lowpass filter frequency response.
figure
semilogx(lpfY.freq, lpfY.level)
xlabel('Frequency (Hz)')
ylabel('Level (dB)')
grid
% Calculate impulse response.
% Convert magnitude and phase data into complex numbers.
lpfYComplexVector = (10.^(lpfY.level/20) .* exp(1i*deg2rad(lpfY.phase)));
lpfX = ifft(lpfYComplexVector, 'symmetric'); % Make output real.
lpfXNorm = lpfX/max(abs(lpfX)); % Normalize output to avoid clipped WAV file.
% Check whether the IFFT was successful.
figure
NFFTCheck = length(lpfXNorm);
YLpfCheck = fft(lpfXNorm, NFFTCheck);
FLpfCheck = ((0:1/NFFTCheck:1-1/NFFTCheck)*Fs).';
magLpfYCheck = 20*log10(abs(YLpfCheck));
semilogx(FLpfCheck, magLpfYCheck)
xlabel('Frequency (Hz)')
ylabel('Level (dB)')
grid
% Save as WAV file.
filename = 'lpf1kHz.wav';
audiowrite(filename, lpfXNorm, Fs);

 Accepted Answer

Hello again,
A friend of mine spotted the problem, which was where the reconstructed frequency index went up to the sampling frequency instead of the Nyquist frequency. After correcting the problem, the corner frequencies of both the original lowpass filter and the reconstructed one match (i.e., –3 dB at 1 kHz).
FLpfCheck = ((0:1/NFFTCheck:1-1/NFFTCheck)*(Fs/2)).';

More Answers (0)

Products

Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!