Index-> contents reference index search Up-> SPT_HELP Data Manipulation Functions resample Prev Next SPT_HELP-> SPTFunctionsByCategory Mathematical Functions Data Manipulation Functions SignalGeneratorMain AnalogFilterFunctions FIR Filter Design Window Functions IIR Filter Design FourierFunctions Plotting Functions Histogram Functions Data Manipulation Functions-> angle revolve shift expand zeropad interpfft resample delavg OtherData resample Headings-> Description Example

Resample a Matrix by Ratio of Intergers
 Syntax `y = resample(`x, Nup, Ndown`)` Include: `include spt\resample.oms` See Also expand , interpfft
``` ARGUMENTS:    INPUTS:         x     = MATRIX, any numerical type.       Nup   = SCALAR, any numerical type, interpolation factor.               Input data is interpolated to Nup times as many               input samples. Coerced to INTEGER before internal               processing.       Ndown = SCALAR, any numerical type, decimation factor.               Every Ndown-th sample of the interpolated data is               returned. Coerced to INTEGER before internal               processing.    RETURN: MATRIX, Column-wise resampled version of input. ```
Description ``` ```Resample input data x by interpolating UP to Nup times the input number of samples, then, decimating down by a factor of Ndown. ``` ```Each column of an input matrix 'x' is resampled by first interpolating up by factor Nup, then decimating down by factor Ndown. Interpolation is done by the SPT function 'interpfft()' which uses a fourier transform method that assumes the data is cyclic. Decimation is done simply choosing every Ndown'th element of the interpolated column. This function simulates resampling a signal to the rational sampling rate Nup/Ndown. Output return length is a function of choice of Nup and Ndown. ``` ```Nup and Ndown are coerced to INTEGER before local processing. Nup and Ndown must each be >= 1 or 'novalue' is returned. If both are equal to 1 the original input is returned. ``` ```Data input may be of any numerical type. Return type is always type DOUBLE. Data input is coerced to DOUBLE before local processing. Row dimension of data input must be at least 2 except for the special case a row vector input which is treated as a column vector with a row vector return.

Example ``` # Interpolate a Squarewave Nup   = 5 Ndown = 3 a     = fill( 1, Nin/4, 1) b     = fill(-1, Nin/4, 1) x     = { a, b, a, b }     # Test signal y     = resample(x, Nup, Ndown) ``` Plotting both input and output: ``` ```