Engee documentation

decimate

Page in progress.

Decimation is a decrease in the sampling rate by an integer number of times.

Library

EngeeDSP

Syntax

Function call

  • y = decimate(x::AbstractVecOrMat, r::Real, mode::String) — reduces the sampling rate of the input signal x in r times. Signal output signal y is shortened to r times: `length(y) = ceil(length(x)/r)'. Uses an FIR filter with a finite impulse response, designed with the usage of a Hamming window. The filter has an order of `30'.

  • y = decimate(x::AbstractVecOrMat, r::Real) — the 'decimate` function uses the IIR Chebyshev filter of the 8th order.

  • y = decimate(x::AbstractVecOrMat, r::Real, n::Real, mode::String) — uses a FIR filter designed with the usage of a Hamming window. The filter has the order n.

  • y = decimate(x::AbstractVecOrMat, r::Real, n::Real) — uses a Chebyshev filter of the order n.

Arguments

Input arguments

# mode — Usage of the FIR filter
String

Details

If the value is set to "fir", then the function decimate uses the function fir1 to design a low-pass FIR filter with a cutoff frequency of 1/r.

# x — Input signal
AbstractVecOrMat

Details

The input signal is in the form of a vector.

Data types

Float32, Float64

# r — decimation coefficient
Real number

Details

The decimation coefficient, specified as a positive integer. For better results when r is greater than 13, divide r by smaller factors and call decimate several times.

Data types

Float32, Float64

# n — filtering order
Real number

Details

The filtering order specified as a positive integer. For an IIR filter, it is not recommended to use a filtering order higher than 13 due to numerical instability. In such cases, the function displays a warning.

Data types

Float32, Float64

Output arguments

# y — a signal with a reduced sampling rate

Details

A signal with a reduced sampling rate.

Data types

Float32, Float64

Algorithms

Decimation reduces the initial sampling rate of the sequence to a lower one. This is the opposite of interpolation. The decimate function applies low-pass filtering to the input signal to protect against spectrum aliasing and decimates the result. The function uses the thinning algorithms 8.2 and 8.3 from [1].

  1. decimate creates a low-pass filter. The Chebyshev I BIH filter is used By default. This filter has a normalized cutoff frequency equal to 0.8/r and a bandwidth ripple equal to 0.05' dB. Sometimes the specified filtering order leads to bandwidth distortion due to rounding errors accumulated as a result of convolutions necessary to create a transfer function. The 'decimate function automatically reduces the filtering order when distortion causes the amplitude response at the cutoff frequency to differ from ripples by more than 10-6.

    When selecting the fir option, the decimate function uses the fir1 function to design a low-pass FIR filter with a cutoff frequency of 1/r.

  2. When using the FIR filter, the decimate function filters the input sequence in only one direction. This saves memory and is useful for working with long sequences. In the case of an IIR filter, the 'decimate` function applies the filter in the forward and reverse directions, using filtfilt to eliminate phase distortion. In essence, this process doubles the filtering order. In both cases, the function minimizes transient effects at both ends of the signal by matching the conditions of the endpoint.

  3. And finally, the 'decimate` function resamples the data by selecting all r points inside the filtered signal. In the resampling sequence (y), y(end) matches 'x(end)` when using the FIR filter, and y(1) corresponds to x(1) when using the FIR filter.

Literature

  1. Digital Signal Processing Committee of the IEEE® Acoustics, Speech, and Signal Processing Society, eds. Programs for Digital Signal Processing. New York: IEEE Press, 1979.