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.
resample()
already implements the filter using polyphase structure) ? $\endgroup$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$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$