Engee documentation

downsample

Reducing the sampling rate by an integer number of times.

Library

EngeeDSP

Syntax

Function call

  • y = downsample(x,n) — reduces the sampling rate x by saving the first selection, and then each n-the th selection after the first one. If x — a matrix, the function treats each column as a separate sequence.

  • y = downsample(x,n,phase) — determines the number of samples by which the sequence must be shifted after lowering the sampling rate.

Arguments

Input arguments

# x — input array

+ vector | the matrix

Details

An input array specified as a vector or matrix. If x — matrix, the function treats columns as independent channels.

# n is the sampling rate reduction factor
a positive integer

Details

The sampling rate reduction factor, set as a positive integer.

Типы данных

Float32, Float64

# phase — offset

+ 0 (by default) | a positive integer

Details

The offset set as a positive integer from 0 before n - 1.

Типы данных

Float32, Float64

Output arguments

# y — array with a reduced sampling rate
vector | the matrix

Details

An array with a reduced sampling rate, returned as a vector or matrix.

Examples

Reducing the sampling rate

Details

Reduce the sampling rate of the sequence to 3 times.

import EngeeDSP.Functions: downsample

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = downsample(x, 3)
4-element Vector{Int64}:
  1
  4
  7
 10

Reduce the sampling rate of the sequence to 3 once and add the phase offset to 2 times.

y = downsample(x, 3, 2)
3-element Vector{Int64}:
 3
 6
 9

Reduce the sampling rate of the matrix to 3 times.

x = [1 2 3; 4 5 6; 7 8 9; 10 11 12]
y = downsample(x, 3)
2×3 Matrix{Int64}:
  1   2   3
 10  11  12