Documentation

downsample

Decrease sample rate by integer factor

Description

example

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

y = downsample(x,n,phase) 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)
y = 1×4

1     4     7    10

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

y = downsample(x,3,2)
y = 1×3

3     6     9

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)
y = 2×3

1     2     3
10    11    12

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.