downsample - Decrease sample rate by integer factor - MATLAB (original) (raw)
Main Content
Decrease sample rate by integer factor
Syntax
Description
[y](#d126e47994) = downsample([x](#d126e47906),[n](#d126e47936))
decreases the sample rate of x
by keeping the first sample and then every n
th sample after the first. Ifx
is a matrix, the function treats each column as a separate sequence.
[y](#d126e47994) = downsample([x](#d126e47906),[n](#d126e47936),[phase](#d126e47960))
specifies the number of samples by which to offset the downsampled sequence.
Examples
Decrease Sample Rates
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
x
— Input array
vector | matrix
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.
n
— Downsampling factor
positive integer
Downsampling factor, specified as a positive integer.
Data Types: single
| double
phase
— Offset
0
(default) | positive integer
Offset, specified as a positive integer from 0 to n – 1.
Data Types: single
| double
Output Arguments
y
— Downsampled array
vector | matrix
Downsampled array, returned as a vector or matrix.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a
R2024a: downsample
supports GPU code generation
The downsample
function supports code generation for graphical processing units (GPUs). You must have MATLAB® Coder™ and GPU Coder™ to generate CUDA® code.