Engee documentation

upsample

Increase the sampling rate by an integer number of times.

Library

EngeeDSP

Syntax

Function call

  • y = upsample(x,n) — increases the sampling rate x by adding n - 1 zeros between counts. If x — a matrix, the function treats each column as a separate sequence.

  • y = upsample(x,n,phase) — determines the number of samples by which the sequence must be shifted after increasing 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 boost factor
a positive integer

Details

The sampling rate boost 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 increased sampling rate
vector | the matrix

Details

An array with an increased sampling rate, returned as a vector or matrix. Output argument y contains x × n counts.

Examples

Increasing the sampling rate

Details

Increase the sampling rate of the sequence in 3 times.

import EngeeDSP.Functions: upsample

x = [1, 2, 3, 4]
y = upsample(x, 3)
12-element Vector{Int64}:
 1
 0
 0
 2
 0
 0
 3
 0
 0
 4
 0
 0

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

x = [1, 2, 3, 4]
y = upsample(x, 3, 2)
12-element Vector{Int64}:
 0
 0
 1
 0
 0
 2
 0
 0
 3
 0
 0
 4

Increase the sampling rate of the matrix in 3 times.

x = [1 2; 3 4; 5 6]
y = upsample(x, 3)
9×2 Matrix{Int64}:
 1  2
 0  0
 0  0
 3  4
 0  0
 0  0
 5  6
 0  0
 0  0