1
$\begingroup$

I am trying to resample a signal using Matlab's resample function. The documentation explains that conceptually, it is upsampling by p, then applying an interpolation filter, then downsampling by q, although it implements it using polyphase filters. If my original sampling rate is $f_s$, the upsampled signal is at rate $pf_s$ and the downsampled signal is at rate $\frac{p}{q}f_s$. I want my interpolation filter to have a cutoff at $\frac{p}{2q}f_s$ (I am downsampling, so q>p), but it is applied to the upsampled signal at rate $pf_s$, so the normalized cutoff frequency is then $\frac{1}{2q}$. I have a large q value (of 35) so my filter requirements are pretty stringent. I am using firls (Matlab's least-squares FIR generator) to try to generate a filter, but even an order 127 filter gives me too high of a cutoff value when I plot using freqz. I am seeing aliasing in the resampled data. I have also tried simply not specifying a filter and using resample with only 3 arguments (Matlab applies a default filter), but it aliases as well. I could always just increase the filter order, but processing time is prohibitive (it seems to be the case that doubling the number of taps roughly doubles the processing time). One of my coworkers suggested using polyphase filters as a way around this problem. I have been working through this document to try to understand how to implement one. From what I understand so far, I see how polyphase filters can be used to make the upsample/filter/downsample process more computationally efficient (and Matlab's resample already uses this), but it seems that polyphase filters use a filter bank based on a "master" filter that would still need a cutoff at $\frac{1}{2q}$. I was hoping maybe there is some simple solution, or perhaps somebody could explain to me how to use polyphase filters to solve this.

Edit: I suppose I should clarify that my cutoff is not right at $\frac{1}{2q}$, but my transition band/cutoff is somewhat lower so this only makes it even more stringent.

$\endgroup$
6
  • $\begingroup$ Why do you want to implement your own polyphase filter? I encourage you to do that regardless for learning purposes, but in a practical case like yours, what's the point (since, as you correctly mentioned, resample() already implements the filter using polyphase structure) ? $\endgroup$
    – Jdip
    Feb 27 at 2:49
  • $\begingroup$ I may be misunderstanding the polyphase filters. It was a suggestion by a senior engineer to help alleviate filter requirements. As far as I can tell, it doesn't seem to. $\endgroup$
    – Levi
    Feb 27 at 2:56
  • 1
    $\begingroup$ He is right to suggest that. Polyphase structures allow for efficient filtering, but as you said, the implementation is the only thing that differs. The actual filter is the same. You also made the point yourself that Matlab already does this under the hood when calling its resample function. I have a hard time believing you have much aliasing... Moreover, look at [y, h] = resample(x, 1, 35). h is the filter used under the hood, and its order is 700. As a matter of fact, the FIR filter order is proportional to $q$. $\endgroup$
    – Jdip
    Feb 27 at 3:01
  • $\begingroup$ My points are: 1) resample is very efficient. It implements the anti-aliasing (or interpolation, depending on whether $p>q$) filter using polyphase structures and implemented in C. 2) The filter order being proportional to the dowsampling (or upsampling) factor, you shouldn't see more or less aliasing for small factors than for larger ones. Happy to continue this conversation in a chat room if you need more. $\endgroup$
    – Jdip
    Feb 27 at 3:10
  • $\begingroup$ It is confusing then why I'm seeing the results I am. I'll have to try again with the default filter and plot it to see for myself. Does this mean that the only real solution is to use a higher filter order? My concern with this is processing time. I have a very large amount of data. Running a filter with 32 taps already takes too long, and it seems like I may need hundreds of taps to get the results I want. $\endgroup$
    – Levi
    Feb 27 at 3:11

1 Answer 1

1
$\begingroup$

The polyphase structure allows for running all the filter banks at the lower sampling rate (the input rate for interpolation, and the output rate for decimation). Regardless the fundamental operation and performance of the filter is identical to the direct approach of upsample - filter - downsample. Whatever requirements are needed for the filter in that case result in the required coefficients for that filter, and those coefficients are then used as the coefficients for the bank of filters in the polyphase approach. So if you have $N$ coefficients, the $M$ polyphase banks will each have $N/M$ coefficients, more filters but all smaller and running at the lower rate which is the efficiency provided.

The filter coefficients map to the polyphase filter banks in row to column form as detailed further in this post: How to implement Polyphase filter?

Further, as detailed here, and not specific to polyphase implementation but the ideal interpolation filter or decimation filter in general, is to use multiband filters which concentrate the rejection at the image locations only (for interpolation) or alias locations only (for decimation) which can lead to significant efficiency improvements if the bandwidth occupied is sufficiently less than Nyquist at the final output rate. For fractional resampling, the multiband filter is designed with the combined rejection considering both the image and alias bands.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.