Learn R Programming

gsignal (version 0.3-7)

downsample: Decrease sample rate

Description

Downsample a signal by an integer factor.

Usage

downsample(x, n, phase = 0)

Value

Downsampled signal, returned as a vector or matrix.

Arguments

x

input data, specified as a numeric vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal.

n

downsampling factor, specified as a positive integer.

phase

offset, specified as a positive integer from 0 to n - 1. Default: 0.

Author

Paul Kienzle, pkienzle@users.sf.net.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Details

For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.

See Also

decimate, resample

Examples

Run this code
x <- seq_len(10)
xd <- downsample(x, 3)     # returns 1  4  7 10
xd <- downsample(x, 3, 2)  # returns 3 6 9

x <- matrix(seq_len(12), 4, 3, byrow = TRUE)
xd <- downsample(x, 3)

Run the code above in your browser using DataLab