interp

Interpolation — increase sampling rate by integer factor

Syntax

• ``````y = interp(x,r)``````
example
• ``````y = interp(x,r,n,alpha)``````
• ``[y,b] = interp(x,r,n,alpha)``

Description

Interpolation increases the original sampling rate of a sequence to a higher rate. It is the opposite of decimation. `interp` inserts 0s into the original signal and then applies a lowpass interpolating filter to the expanded sequence.

example

``````y = interp(x,r)``` increases the sampling rate of `x`, the input signal, by a factor of `r`. The interpolated vector, `y`, is `r` times as long as the original input, `x`.```
``````y = interp(x,r,n,alpha)``` specifies two additional values. `n` is half the number of original sample values used to interpolate the expanded signal. Its default value is 4. It should ideally be less than or equal to 10. `alpha` is the normalized cutoff frequency of the input signal, specified as a fraction of the Nyquist frequency. It defaults to 0.5. The lowpass interpolation filter has length `2*n*r + 1`.```
````[y,b] = interp(x,r,n,alpha)` also returns a vector, `b`, with the filter coefficients used for the interpolation. ```

Input Arguments

collapse all

`x` — Input signalvector

Input signal, specified as a vector.

Data Types: `double`

`r` — Interpolation factorpositive integer scalar

Interpolation factor, specified as a positive integer scalar.

Data Types: `double`

`n` — Half-number of input samples used for interpolation4 (default) | positive integer scalar

Half-number of input samples used for interpolation, specified as a positive integer scalar. `n` should never be greater than 10.

Data Types: `double`

`alpha` — Normalized cutoff frequency0.5 (default) | positive scalar

Normalized cutoff frequency of the input signal, specified as a positive real scalar not greater than 1. A value of 1 means that the signal occupies the full Nyquist interval.

Data Types: `double`

Output Arguments

collapse all

`y` — Interpolated signalvector

Interpolated signal, returned as a vector.

Data Types: `double`

`b` — Lowpass interpolation filter coefficientscolumn vector

Lowpass interpolation filter coefficients, returned as a column vector.

Data Types: `double`

Examples

collapse all

Interpolate a Signal

Create a sinusoidal signal sampled at 1 kHz. Interpolate it by a factor of four.

```t = 0:0.001:1; x = sin(2*pi*30*t) + sin(2*pi*60*t); y = interp(x,4); ```

Plot the original and interpolated signals.

```subplot 211 stem(0:30,x(1:31),'filled','markersize',3) grid on xlabel 'Sample number',ylabel Original subplot 212 stem(0:120,y(1:121),'filled','markersize',3) grid on xlabel 'Sample number',ylabel Interpolated ```

expand all

Algorithms

`interp` uses the lowpass interpolation algorithm 8.1 described in [1].

1. It expands the input vector to the correct length by inserting 0s between the original data values.

2. It designs a special symmetric FIR filter that allows the original data to pass through unchanged and interpolates to minimize the mean-square error between the interpolated points and their ideal values. The filter used by `interp` is the same as the filter returned by `intfilt`.

3. It applies the filter to the expanded input vector to produce the output.

References

[1] Digital Signal Processing Committee of the IEEE Acoustics, Speech, and Signal Processing Society, eds. Programs for Digital Signal Processing. New York: IEEE Press, 1979, chap. 8.

[2] Oetken, G., Thomas W. Parks, and H. W. Schüssler. "New results in the design of digital interpolators." IEEE® Transactions on Acoustics, Speech, and Signal Processing. Vol. ASSP-23, 1975, pp. 301–309.

Get trial now