# Downsampling data

## Description

Downsampling is the process of reducing the sampling rate of a signal. Downsample reduces the sampling rate of the input AOs by an integer factor by picking up one out of N samples. Note that no anti-aliasing filter is applied to the original data. Moreover, a offset can be specified, i.e., the sample at which the output data starts ---see examples below.

## Syntax

```
b = downsample(a, pl)
```

## Parameters

The following parameters can be set in this method:

• factor - decimation factor [by default is 1: no downsampling] (must be an integer)
• offset - sample offset for decimation

## Examples

1. Downsampling a sequence of random data at original sampling rate of 10 Hz by a factor of 4 (fsout = 2.5 Hz) and no offset.

```
% create an AO of random data with fs = 10 Hz
pl      = plist('tsfcn', 'randn(size(t))','fs',10,'nsecs',10,'yunits','m');
x       = ao(pl)
pl_down = plist('factor', 4);     % add the decimation factor
y       = downsample(x, pl_down); % downsample the input AO, x
iplot(x, y)
```

2. Downsampling a sequence of random data at original sampling rate of 10 Hz by a factor of 4 (fsout = 2.5 Hz) and offset = 10.

```
% create an AO of random data with fs = 10 Hz
pl         = plist('tsfcn', 'randn(size(t))','fs',10,'nsecs',10,'yunits','m');
x          = ao(pl)
pl_downoff = plist('factor', 4,'offset',10);  % add the decimation factor and the offset parameter
y          = downsample(x, pl_downoff);       % downsample the input AO, x
iplot(x, y)
```