cost

Estimate cost of discrete-time or multirate filter

Syntax

c = cost(hd)
c = cost(hm)
c = cost(hs)
c = cost(hs,Name,Value)

Description

c = cost(hd) returns a cost estimate c for the discrete-time filter hd.

c = cost(hm) return a cost estimate c for the multirate filter hm.

c = cost(hs) returns a cost estimate c for the filter System object™ hs.

c = cost(hs,Name,Value) returns a cost estimate c for the filter System object hs with additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

hd

Discrete-time dfilt filter object.

hm

Multirate mfilt filter object.

hs

Filter System object.

The following Filter System objects are supported by this analysis function:

Filter System objects
dsp.FIRFilter
dsp.FIRInterpolator
dsp.CICInterpolator
dsp.FIRDecimator
dsp.CICDecimator
dsp.FIRRateConverter
dsp.BiquadFilter
dsp.IIRFilter
dsp.AllpoleFilter
dsp.AllpassFilter
dsp.CoupledAllpassFilter

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Arithmetic' — Value types:‘double' | 'single' | 'fixed'

For filter System object inputs only, specify the arithmetic used during analysis. When you specify 'double' or 'single', the function performs double- or single-precision analysis. When you specify 'fixed' , the arithmetic changes depending on the setting of the CoefficientDataType property and whether the System object is locked or unlocked.

 Details for Fixed-Point Arithmetic

When you do not specify the arithmetic for non-CIC structures, the function uses double-precision arithmetic if the filter System object is in an unlocked state. If the System object is locked, the function performs analysis based on the locked input data type. CIC structures only support fixed-point arithmetic.

Output Arguments

c

Cost estimate. c has the following fields.

Estimated Value

Field Name

Description

Number of Multiplications

nmult

Number of multiplications during the filter run. nmult ignores multiplications by -1, 0, and 1 in the total multiple.

Number of Additions

nadd

Number of additions during the filter run.

Number of States

nstates

Number of states the filter uses.

Multiplications per Input Sample

multperinputsample

Number of multiplication operations performed for each input sample

Additions per Input Sample

addperinputsample

Number of addition operations performed for each input sample

Examples

These examples show you the cost method applied to dfilt and mfilt objects.

hd = design(fdesign.lowpass);
c = cost(hd);

When you are using a multirate filter object, cost works the same way.

d = fdesign.decimator(4,'cic');
hm = design(d,'multisection');

See Also

Was this topic helpful?