Documentation Center |
Direct-form FIR polyphase fractional decimator
hm = mfilt.firfracdecim(l,m,num)
mfilt.firfracdecim will be removed in a future release. Use mfilt.firsrc instead.
hm = mfilt.firfracdecim(l,m,num) returns a direct-form FIR polyphase fractional decimator. Input argument l is the interpolation factor. l must be an integer. When you omit l in the calling syntax, it defaults to 2. m is the decimation factor. It must be an integer. If not specified, it defaults to l+1.
num is a vector containing the coefficients of the FIR lowpass filter used for decimation. If you omit num, a lowpass Nyquist filter of gain l and cutoff frequency of π/max(l,m) is used by default.
By specifying both a decimation factor and an interpolation factor, you can decimate your input signal by noninteger amounts. The fractional decimator first interpolates the input, then decimates to result in an output signal whose sample rate is l/m of the input rate. By default, the resulting decimation factor is 2/3 when you do not provide l and m in the calling syntax. Specify l smaller than m for proper decimation.
The following table describes the input arguments for creating hm.
Input Argument | Description |
---|---|
l | Interpolation factor for the filter. It must be an integer. When you do not specify a value for l it defaults to 2. |
num | Vector containing the coefficients of the FIR lowpass filter used for decimation. When num is not provided as an input, firfracdecim uses a lowpass Nyquist filter with gain equal to l and cutoff frequency equal to π/max(l,m) by default. |
m | Decimation factor for the filter. m specifies the amount to reduce the sampling rate of the input signal. It must be an integer. When you do not specify a value for m it defaults to l + 1. |
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.firfracdecim objects. The next table describes each property for an mfilt.firfracdecim filter object.
Name | Values | Description |
---|---|---|
FilterStructure | String | Reports the type of filter object, such as a decimator or fractional decimator. You cannot set this property — it is always read only and results from your choice of mfilt object. |
InputOffset | Integers | Contains the number of input data samples processed without generating an output sample. The default value is 0. |
Numerator | Vector | Vector containing the coefficients of the FIR lowpass filter used for interpolation. |
RateChangeFactors | [l,m] | Reports the decimation (m) and interpolation (l) factors for the filter object. Combining these factors results in the final rate change for the signal. |
PersistentMemory | false or true | Determines whether the filter states are restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter if you have not changed the filter since you constructed it. PersistentMemory returns to zero any state that the filter changes during processing. States that the filter does not change are not affected. |
States | Matrix | Stored conditions for the delays between each interpolator phase, the filter states, and the states at the output of each phase in the filter. The number of states is (lh-1)*m+(l-1)*(lo+mo) where lh is the length of each subfilter, and l and m are the interpolation and decimation factors. lo and mo, the input and output delays between each interpolation phase, are integers from Euclid's theorem such that lo*l-mo*m = -1 (refer to the reference for more details). Use euclidfactors to get lo and mo for an mfilt.firfracdecim object |
To demonstrate firfracdecim, perform a fractional decimation by a factor of 2/3. This is one way to downsample a 48 kHz signal to 32 kHz, commonly done in audio processing.
l = 2; m = 3; % Interpolation/decimation factors. hm = mfilt.firfracdecim(l,m); % We use the default fs = 48e3; % Original sample freq: 48 kHz. n = 0:10239; % 10240 samples, 0.213 second long % signal x = sin(2*pi*1e3/fs*n); % Original signal, sinusoid at 1 kHz y = filter(hm,x); % 9408 samples, still 0.213 seconds stem(n(1:49)/fs,x(1:49)); hold on; % Plot original signal sampled % at 48 kHz stem(n(1:32)/(fs*l/m),y(13:44),'r','filled') % Plot decimated % signal at 32 kHz xlabel('Time (sec)');
As shown, the plot clearly demonstrates the reduced sampling frequency of 32 kHz.