RESAMPLE

Purpose:

Resamples a series to an arbitrary sample rate.

Syntax:

RESAMPLE(series, rate, "method")

series

-

Input series to resample.

rate

-

A real, the new sample rate where rate > 0.

"method"

-

Optional. A string, the interpolation method.

"linear"

:

linear interpolation (default)

"spline"

:

cubic spline interpolation

"sinc"

:

standard sin(x)/x interpolation

"sinx"

:

FFT based periodic sin(x)/sin interpolation

"none"

:

nearest neighbor (no interpolation) 

Alternate Syntax:

RESAMPLE(xseries, yseries, rate, "method")

xseries

-

Input X series to resample

yseries

-

Input Y series to resample.

rate

-

A real, the new sample rate where rate > 0.

"method"

-

Optional. A string, the interpolation method.

"linear"

:

linear interpolation (default)

"spline"

:

cubic spline interpolation

"sinc"

:

standard sin(x)/x interpolation

"sinx"

:

FFT based periodic sin(x)/sin interpolation

"none"

:

nearest neighbor (no interpolation) 

Returns:

An interval series where the Y values are sampled at the new rate.

Example:

W1: {1, 2, 3, 2}

W2: resample(W1, 3)

W3: W1;overp(W2, seriesred);setsym(14,2);setplotstyle(1,2)

 

image\resample1.png

 

W1 contains the source series with a sample rate of 1.

 

W2 linearly resamples W1 to a rate of 3.0 and produces a 10 point series. The time duration of W2 is the same as W1.

 

W3 displays the original series with the resampled values overplotted as red circles.

Example:

W4: resample(W1, 3, "spline")

 

Same as above except cubic spline interpolation is performed.

Example:

W1: gsin(100, 1/100, 20)

W2: resample(W1, 1000);overp(W1);setplotstyle(1, 2);setsym(circle, 2)

W3: resample(W1, 1000, "sinc");overp(W1);setplotstyle(1, 2);setsym(circle, 2)

 

image\resample2.png

 

W1 generates 100 samples of a 20 Hz sine wave sampled at 100 Htz.

 

W2 linearly resamples W1 to a sample rate of 1000 Hz. The original data is overplotted in red circles.

 

W3 resamples W1 to a sample rate of 1000 Hz using the "sinc" (i.e. sin(x)/x) interpolation method. The original data is overplotted in red circles. The resampled data accurately constructs the underlying 20 Hz sine wave.

Remarks:

The new sample rate must be greater than 0.

 

If the new rate is less than the original rate, decimation is performed.

 

If the input is an XY series, an evenly sampled interval series is returned.

 

The "sinc" method implements standard bandlimited sin(x)/x interpolation.

 

The "sinx" method implements bandlimited sin(Nx)/sin(x) periodic interpolation using the FFT zero insertion method of ZINTERP.

See Also:

DECILP

DECIMATE

DOWNSAMPLE

INTERPOLATE

SPLINE

TIMESYNC

UPSAMPLE

XY

XYINTERP

XYLOOKUP

ZINTERP