How can I export the coefficients of one equivalent FIR filter when I have designed two multirate filters in FDATool?

7 views (last 30 days)
I have designed and cascaded two multi-rate filters in FDATool and I would like to export the coefficients of an equivalent one-stage FIR filter.
The first stage is an FIR filter with 18 coefficients and a decimation by 2. The second stage is an FIR filter with 60 coefficients and another decimation by 2. When I combine them in FDATool, the resulting filter has 137 coefficients which doesn't make sense.
When I try to export the coefficients to the MATLAB Workspace as coefficients, I only get the coefficiencts of the two stages separately. How can I combine the two?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The reason that there are 137 coefficients for the equivalent filter formed from the two multi-rate filters given in the example is that the first stage with 18 coefficients is followed by decimation by 2. Therefore the second filter stage only operates on every other sample. To combine the two filters into one you must upsample the second stage's coefficients and then convolve the result with the first stage's coefficients. From the example: stage one has 18 taps and stage two has 60 taps and therefore the result will have 60*2 + 18 -1 = 137 taps.
Although there are no ways of directly exporting the equivalent FIR filter formed from two cascaded filters, here are two workarounds:
1.) You can export each stage's coefficients to the Workspace as Filter Objects and then combine them using upsampling with zeros and
convolution.
To export the coefficients as Objects go to File -> Export then select to Workspace as Objects. Once the objects are in the Workspace
you can use the UPSAMPLE and CONV functions to obtain the overall system's coefficients. See the following example code:
myFilt = conv(Hd.Stage(1).Numerator, upsample(Hd.Stage(2).Numerator,2));
Hfir = dfilt.dffir( myFilt );
% Remove trailing zero
Hfir.Numerator(end) = [ ];
For more information on UPSAMPLE and CONV type 'doc upsample' and 'doc conv' at the MATLAB command prompt.
2.) A second method for extracting the overall system coefficients uses the TF command. Once you have exported the Filter Objects to the
MATLAB Workspace, use the following example code:
[b,a] = tf(Hd);
The variable 'b' now contains the 137 coefficients plus an extra zero term at the end.
While these give the equivalent FIR filter representing 2 cascaded multi-rate filters, this may not be the most efficient
implementation. For instance, the COST function of the Filter Design Toolbox can put this in better perspective:
From the first example:
cost(Hd) % The cost of the original cascaded filter
ans =
Number of Multipliers : 79
Number of Adders : 77
Number of States : 76
MultPerInputSample : 24.25
AddPerInputSample : 23.5
cost(hfir) % The cost of the equivalent one-stage filter
ans =
Number of Multipliers : 138
Number of Adders : 137
Number of States : 137
MultPerInputSample : 138
AddPerInputSample : 137
For more information on the COST function, type 'doc cost' at the MATLAB command prompt.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2006a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!