# downsample

Decrease sample rate of `tireData` object by integer factor

Since R2024a

## Syntax

``obj = downsample(obj,n)``
``obj = downsample(___,offset)``

## Description

````obj = downsample(obj,n)` decreases the sample rate of each data channel in the `tireData` object specified by `obj`, keeping the first sample and then every nth sample specified by `n`. ```

example

````obj = downsample(___,offset)` offsets the downsampled sequence by the number of samples specified by `offset`. ```

## Examples

collapse all

Use the `downsample` function to decrease the sample rate of imported tire measurement data.

Import and View Tire Measurement Data

Import tire measurement data into a `tireData` object, `td`.

`td = tireData("example_data.tdx");`

Multiple `Fz` conditions are included in the data. Use the `split` function to separate the data by tire data channel F`z`, resulting in four `tireData` objects.

`td = split(td,"Fz");`

Use the `plot` function to view the lateral force versus the slip angle using the normal force to assign colors and legend values.

`plot(td,DataVariableNames=["alpha","Fy"],ColorBy="Fz");`

Downsample Tire Measurement Data

Use the `downsample` function to decrease the sample rate of all the data channels in the `tireData` object array `td`.

`tdDown = downsample(td,5);`

Plot the resulting `tireData` objects in `tdDown` to visualize the modified data set.

`plot(tdDown,DataVariableNames=["alpha","Fy"],ColorBy="Fz");`

Downsample Tire Measurement Data with Offset

Specify offset to define the number of samples to offset the downsampled sequence.

`tdDown = downsample(td,5,10);`

Plot the resulting `tireData` objects in `tdDown` to visualize the modified data set.

`plot(tdDown,DataVariableNames=["alpha","Fy"],ColorBy="Fz")`

## Input Arguments

collapse all

Tire data, specified as a `tireData` object or an array of `tireData` objects.

Downsampling factor, specified as a positive integer.

Data Types: `int8` | `int16` | `int32` | `int64`

Number of samples to offset the downsampled sequence, specified as a positive integer.

Data Types: `int8` | `int16` | `int32` | `int64`

## Output Arguments

collapse all

Downsampled tire data, returned as a `tireData` object or an array of `tireData` objects.

## Version History

Introduced in R2024a