Dear Community,
I am trying to build a low-pass filter by using a sinc function for my homework assignment. I then use convolution to later filter an audio sample with this filter. However, when I plot the filter in a bode plot it looks like a high-pass filter. Can anyone tell me what I'm doing wrong?
Thanks in advance!
%% Downsampled by K with low-pass filter
% Build filter
clear all; close allK = 2;fs = 1600;N = 51;n = (-(N-1)/2:1:(N-1)/2);h = (1/K) * sinc((pi/K)*n);% Plot frequency response filter
[H, H_vec] = fftFreq(h, fs, 1 );figureplot(H_vec*2*pi/fs, abs(H))filt_tf =tf(h,1,1/fs,'Variable','z^-1');figurebode(filt_tf)function [ X , f ] = fftFreq( data , fs, w )% Number of FFT points
NFFT = length( data );% calculate FFT
X = fft(data .* w);% calculate frequency spacing
df = fs/NFFT;% calculate unshifted frequency vector
f = (0:(NFFT-1)) * df;end
Best Answer