Space Data Equally in One Variable (space_data_equally​)

version 2.0.1 (81.2 KB) by
Interpolates unequally spaced data to make it equally spaced in the independent variable.

Updated 28 Aug 2021

From GitHub

`space_data_equally`

Interpolates unequally spaced data to make it equally spaced in the independent variable.

Syntax

`[x_new,y_new] = space_data_equally(x,y,dx)`
`[x_new,y_new] = space_data_equally(x,y,dx,method)`

Description

`[x_new,y_new] = space_data_equally(x,y,dx)` linearly interpolates the data stored in `x` and `y` so that the data points in the `x` direction have an equal spacing of `dx`. The equally spaced data is returned in the vectors `x_new` and `y_new`.

`[x_new,y_new] = space_data_equally(x,y,dx,method)` interpolates the data stored in `x` and `y` so that the data points in the `x` direction have an equal spacing of `dx`. The input variable `method` corresponds to the interpolation method, and can be specified as `'linear'`, `'nearest'`, `'next'`, `'previous'`, `'pchip'`,`'cubic'`,`'v5cubic'`,`'makima'`, or `'spline'` (see `interp1` documentation for explanation). The equally spaced data is returned in the vectors `x_new` and `y_new`.

NOTE: If the length of `x` is not an integer multiple of `dx`, then the spacing between the last two points in `x_new` will not be equal to `dx`, as the function manually fixes the last element of `x` to be equal to the last element of `x_new`. The rest of the points will still be equally spaced.

Examples

See "EXAMPLES.mlx" or the "Examples" tab on the File Exchange page for examples.

Cite As

Tamas Kis (2021). Space Data Equally in One Variable (space_data_equally) (https://github.com/tamaskis/space_data_equally-MATLAB/releases/tag/v2.0.1), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux