I am new to DSP, and currently trying to implement a simple polyphase decimation program in matlab.
M is decimation factor, x is input (for now it is a square wave 8096 samples), y_polyDec is result from polyphase, output is result from regular filter then decimation.
FilterBank_LPF = fir1(127, 1/M); y_polyDec = zeros(8096/M, 1); for i = 1:M p(:, i) = FilterBank_LPF(i:M:end); x(:, i) = input(M-i+1:M:end); y_polyDec = filter(p(:, i), 1, x(:, i))+ y_polyDec; end out_LPF = filter(FilterBank_LPF, 1, input); output = downsample(out_LPF, M); %===========================================
If I compare "output" and "y_polyDec" (either comparing the decimated sample values or frequency spectrum using fvtool) I notice there are differences in the values. I was wondering if my code is wrong, or am I still missing something.