downsample - Decrease sample rate by integer factor - MATLAB (original) (raw)

Main Content

Decrease sample rate by integer factor

Syntax

Description

[y](#d126e54645) = downsample([x](#d126e54557),[n](#d126e54587)) decreases the sample rate of x by keeping the first sample and then every nth sample after the first. Ifx is a matrix, the function treats each column as a separate sequence.

example

[y](#d126e54645) = downsample([x](#d126e54557),[n](#d126e54587),[phase](#d126e54611)) specifies the number of samples by which to offset the downsampled sequence.

Examples

collapse all

Decrease the sample rate of a sequence by a factor of 3.

x = [1 2 3 4 5 6 7 8 9 10]; y = downsample(x,3)

Decrease the sample rate of the sequence by a factor of 3 and add a phase offset of 2.

Decrease the sample rate of a matrix by a factor of 3.

x = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; y = downsample(x,3)

Input Arguments

collapse all

Input array, specified as a vector or matrix. If x is a matrix, the function treats the columns as independent channels.

Example: cos(pi/4*(0:159)) + randn(1,160) specifies a sinusoid embedded in white Gaussian noise.

Example: cos(pi./[4;2]*(0:159))' + randn(160,2) specifies a two-channel noisy sinusoid.

Downsampling factor, specified as a positive integer.

Data Types: single | double

Offset, specified as a positive integer from 0 to n – 1.

Data Types: single | double

Output Arguments

collapse all

Downsampled array, returned as a vector or matrix.

Extended Capabilities

Version History

Introduced before R2006a

expand all

The downsample function supports code generation for graphical processing units (GPUs). You must have MATLAB® Coder™ and GPU Coder™ to generate CUDA® code.