%% Determine the Polyphase Subfilters of an FIR Interpolator
% Note: If you are using R2016a or earlier, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).
% The dsp.Interpolator object with the Method property set to 'FIR' models a polyphase FIR Interpolator. The polyphase implementation splits the lowpass FIR filter impulse response into several subfilters. Each subfilter occupies a specific narrow frequency band. This example shows how to determine the polyphase subfilters.
% The default upsampling factor and the default polyphase half-length is 3. Using these values, design the linear phase FIR filter by using the intfilt function. The filter returned is of length 2 * P * L -1, where P is the upsampling factor and L is the filter half length.

interp = dsp.Interpolator('Method','FIR');
L = interp.InterpolationPointsPerSample;
P = interp.FilterHalfLength;
FiltCoeffs = intfilt(L,P,interp.Bandwidth);
FiltLen=length(FiltCoeffs);
FiltCols = ceil(FiltLen/2/L);

%
% The filter needs 2*P*L coefficients. Prepending a zero does not affect the filter magnitude.

FiltCoeffs = [zeros(FiltCols*2*L-FiltLen,1); FiltCoeffs(:)];

%
% Each column of PolyPhaseCoeffs is a polyphase subfilter.

PolyPhaseCoeffs  = reshape(FiltCoeffs,FiltCols,2*L)';

% Copyright 2012 The MathWorks, Inc.