Qu

upsample

Builtin index · Signal processing

result = upsample(x, L, [order=60], [fs=])

Input: x, L, order, fs · Output: result

What it is

x: a length-N vector or Signal; L: a whole number ≥ 1, the integer interpolation factor; order (optional, even, default 60): the FIR interpolation filter's order; fs (optional): the input sample rate, defaulting to the Signal's own Fs or 1.0 for a plain vector. Raises the sample rate by an integer factor: inserts L-1 zeros between samples, then interpolates with a lowpass at the original Nyquist (fs/2), scaled by L to preserve amplitude. That interpolation filter runs at the new rate fs*L, and the gain of L is what stops the zero-stuffing dividing the amplitude by L.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = upsample(x, L, [order=60], [fs=])
x vector or Signalx: a length-N vector or Signal.
L numberL: a whole number ≥ 1, the integer interpolation factor.
order optional (default 60)order (optional, even, default 60): the FIR interpolation filter's order.
fs Signal or vector, optionalfs (optional): the input sample rate, defaulting to the Signal's own Fs or 1.0 for a plain vector.
result Signal or vector
Returns N*L samples — a Signal at Fs = fs*L if x was one, a plain vector otherwise. The filter is causal, so the output is delayed by order/2 samples at the OUTPUT rate (30 samples by default), which is order/(2*fs*L) seconds. L = 1 is the identity, with no filter and no delay. Added in v0.3.0.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

upsample(x, L, [order=], [fs=]) — zero-stuff by L, then interpolate with a lowpass at the ORIGINAL Nyquist (fs/2) running at the NEW rate (fs*L), scaled by L to restore the amplitude the zero-stuffing divided away (stuffing L-1 zeros spreads the same energy over L times as many samples, so the interpolated result comes out at 1/L of the input's amplitude without the gain — the same L factor MATLAB's interp and scipy's resample_poly apply). Group delay: order/2 samples at the OUTPUT rate fs*L (30 output samples at the default order 60), i.e. order/(2*fs*L) seconds.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.