I implemented a polyphase filter function for interpolating and decimating. It works great (I compared it to what I'd get by interp/decim by inserting L-1 zeros and I get the same results) except for when I compensate delay.
I mean, what I'm doing basically is pulse-shaping with a b=rcosdesign(0.35,4,3,'sqrt'); matlab built-in function (13 taps, so delay is 6). Then I proceed as follows:
Non-polyphase
Upsample by M=3 then x=filter(b.*M,1,upsampled_data). After that, I filter again r=filter(b,1,x) and then I downsample downsample(r(mean(grpdelay(b))*2+1:end),M). As you can see, I'm removing the delay generetad by both filters.
Polypase
I have my custom function so in two lines I run:
x_p = polyfilter( data, b.*M, M, 'interpolation' );
rd_p= polyfilter( x_p(mean(grpdelay(b))*2+1:end), b, M, 'decimation' );
But when I plot the results, only the non-polyphase process 100% matches the original data, while the polyphase one doesn't. You can see such plot here:

When I'm not taking the delay into account, both non-polyphase and polyphase filters output the exact same thing. I kind of understand that I'm not removing the delay at the exact same part of the process in both cases, because I'm removing it right before removing L-1 zeros but after filtering in the non-polyphase case, and in polyphase case I'm removing the delay right before filtering, and I think the correct one is the non-polyphase one but I'm not too sure when I should remove the delay in the polyphase case.
Thanks.
Regarding delays and FIR filters, polyphase is just an efficient implementation, it will not change the output compared to a regular FIR filter followed by a decimation.
Suppose an N-tap symmetrical filter, the group delay will be (N-1)/2
If you decimate by D, the group delay will be (N-1)/(2*D).
However, that's true if you choose the first sample out of D, if instead you select the 2nd sample out of D, the group delay will be smaller (don't recall the exact formula, might be N/(2*D) )
– Ben Aug 21 '19 at 15:49As for what you say about the group delay being (N-1)/(2*D), does that mean I can remove that after downsampling? I'll check that out, thanks!
– researcher9 Aug 21 '19 at 17:02