This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Linear interpolator

mfilt.linearinterp will be removed in a future release. Use idsp.CICInterpolator (with NumSections = 2) instead.


hm = mfilt.linearinterp(l)


hm = mfilt.linearinterp(l) returns an FIR linear interpolator hm with an integer interpolation factor l. Provide l as a positive integer. The default value for the interpolation factor is 2 when you do not include the input argument l.

When you use this linear interpolator, the samples added to the input signal have values between the values of adjacent samples in the original signal. Thus you see something like a smooth profile where the interpolated samples continue a line between the previous and next original samples. The example demonstrates this smooth profile clearly. Compare this to the interpolation process for mfilt.holdinterp, which creates a stairstep profile.

Make this filter a fixed-point or single-precision filter by changing the value of the Arithmetic property for the filter hm as follows:

  • To change to single-precision filtering, enter

  • To change to fixed-point filtering, enter


Input Arguments

The following table describes the input argument for mfilt.linearinterp.

Input Argument



Interpolation factor for the filter. l specifies the amount to increase the input sampling rate. It must be an integer. When you do not specify a value for l it defaults to 2.

Object Properties

This section describes the properties for both floating-point filters (double-precision and single-precision) and fixed-point filters.

Floating-Point Filter Properties

Every multirate filter object has properties that govern the way it behaves when you use it. Note that many of the properties are also input arguments for creating mfilt.linearinterp objects. The next table describes each property for an mfilt.linearinterp filter object.





Double, single, fixed

Specifies the arithmetic the filter uses to process data while filtering.



Reports the type of filter object. You cannot set this property — it is always read only and results from your choice of mfilt object.



Interpolation factor for the filter. l specifies the amount to increase the input sampling rate. It must be an integer.


'false' or 'true'

Determine whether the filter states get restored to zero for each filtering operation


Double or single array

Filter states. states defaults to a vector of zeros that has length equal to nstates(hm). Always available, but visible in the display only when PersistentMemory is true.

Fixed-Point Filter Properties

This table shows the properties associated with the fixed-point implementation of the mfilt.holdinterp filter.


The table lists all of the properties that a fixed-point filter can have. Many of the properties listed are dynamic, meaning they exist only in response to the settings of other properties. To view all of the characteristics for a filter at any time, use


where hm is a filter.

For further information about the properties of this filter or any mfilt object, refer to Multirate Filter Properties.





Any positive or negative integer number of bits. Depends on L. [29 when L=2]

Specifies the fraction length used to interpret data output by the accumulator.


Any integer number of bits [33]

Sets the word length used to store data in the accumulator.


fixed for fixed-point filters

Setting this to fixed allows you to modify other filter properties to customize your fixed-point filter.


[true], false

Specifies whether the filter automatically chooses the proper fraction length to represent filter coefficients without overflowing. Turning this off by setting the value to false enables you to change the NumFracLength property value to specify the precision used.


Any integer number of bits [16]

Specifies the word length to apply to filter coefficients.


[FullPrecision], SpecifyPrecision

Controls whether the filter automatically sets the output word and fraction lengths, product word and fraction lengths, and the accumulator word and fraction lengths to maintain the best precision results during filtering. The default value, FullPrecision, sets automatic word and fraction length determination by the filter. SpecifyPrecision makes the output and accumulator-related properties available so you can set your own word and fraction lengths for them.


Any positive or negative integer number of bits [15]

Specifies the fraction length the filter uses to interpret input data.


Any integer number of bits [16]

Specifies the word length applied to interpret input data.


Any positive or negative integer number of bits [14]

Sets the fraction length used to interpret the numerator coefficients.


Any positive or negative integer number of bits [29]

Determines how the filter interprets the filter output data. You can change the value of OutputFracLength when you set FilterInternals to SpecifyPrecision.


Any integer number of bits [33]

Determines the word length used for the output data. You make this property editable by setting FilterInternals to SpecifyPrecision.


saturate, [wrap]

Sets the mode used to respond to overflow conditions in fixed-point arithmetic. Choose from either saturate (limit the output to the largest positive or negative representable value) or wrap (set overflowing values to the nearest representable value using modular arithmetic.) The choice you make affects only the accumulator and output arithmetic. Coefficient and input arithmetic always saturates. Finally, products never overflow — they maintain full precision.


[convergent], ceil, fix, floor, nearest, round

Sets the mode the filter uses to quantize numeric values when the values lie between representable values for the data format (word and fraction lengths).

  • ceil - Round toward positive infinity.

  • convergent - Round to the closest representable integer. Ties round to the nearest even stored integer. This is the least biased of the methods available in this software.

  • fix - Round toward zero.

  • floor - Round toward negative infinity.

  • nearest - Round toward nearest. Ties round toward positive infinity.

  • round - Round toward nearest. Ties round toward negative infinity for negative numbers, and toward positive infinity for positive numbers.

The choice you make affects only the accumulator and output arithmetic. Coefficient and input arithmetic always round. Finally, products never overflow — they maintain full precision.


[true], false

Specifies whether the filter uses signed or unsigned fixed-point coefficients. Only coefficients reflect this property setting.


fi object

Contains the filter states before, during, and after filter operations. States act as filter memory between filtering runs or sessions. The states use fi objects, with the associated properties from those objects. For details, refer to fixed-point objects in Fixed-Point Designer™ documentation. For information about the ordering of the states, refer to the filter structure in the following section.

Filter Structure

Linear interpolator structures depend on the FIR filter you use to implement the filter. By default, the structure is direct-form FIR.


Interpolation by a factor of 2 (used to convert the input signal sampling rate from 22.05 kHz to 44.1 kHz).

l = 2;                      % Interpolation factor
hm = mfilt.linearinterp(l);
fs = 22.05e3;               % Original sample freq: 22.05 kHz.
n = 0:5119;                 % 5120 samples, 0.232 second long signal
x  = sin(2*pi*1e3/fs*n);    % Original signal, sinusoid at 1 kHz
y = filter(hm,x);           % 10240 samples, still 0.232 seconds
stem(n(1:22)/fs,x(1:22),'filled') % Plot original sampled at
                                  % 22.05 kHz
hold on                     % Plot interpolated signal (44.1
                            % kHz) in red
xlabel('Time (s)');ylabel('Signal Value')

Using linear interpolation, as compared to the hold approach of mfilt.holdinterp, provides greater fidelity to the original signal.

Introduced in R2011a

Was this topic helpful?