## FANDOM

133 Pages

Decimation stretches a spectrum - all the frequencies are increased by the decimation factor and all the magnitudes are reduced by the decimation factor.

Interpolation compresses a spectrum - all the frequencies are reduced by the decimation. However, the magnitudes remain the same.

To work out the interpolation factor L and decimation factor M required to resample a signal by a non-integer factor, see that

$f_{old}\frac{L}{M} = f_{new}$

$\frac{L}{M} = \frac{f_{new}}{f_{old}}$

Reduce the fraction on the right by dividing the numerator and denominator by their greatest common divisor.

Being really lazy, I wrote a short python function to do this for me while doing tutorial 9.

def gcd(a,b):
"""Return the greatest common divisor of the two arguments"""
if a < b:
a,b = b,a
c = a % b
if c == 0:
return b
else:
return gcd(b,c)

def resample(fold,fnew):
"""Return the upsampling and downsampling factors required to resample
fold to fnew"""
i = gcd(fold,fnew)
return fnew/i,fold/i

## Cutoff Frequency of the required Low Pass Filter Edit

You need to prevent aliasing from occurring at the lowest sampling frequency. So you basically take the smallest out of $\frac{f_{old}}{2}$ and $\frac{f_{new}}{2}$.

## Why you should use a FIR Filter for Downsampling Edit

Remember, when you downsample, you decimate the signal, so you're only using every Mth sample. An IIR filter needs to be evaluated for every sample, as it relies on its previously calculated values. A FIR filter doesn't rely on its previously calculated values, so you can get away with only evaluating it on every Mth sample! Which reduces the amount of processing required by M.

Community content is available under CC-BY-SA unless otherwise noted.