This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

scale

Scale second-order sections of dsp.BiquadFilter System object

Syntax

scale(biquad)
biquadnew = scale(biquad)
scale(biquad,pnorm)
scale(biquad,pnorm,opts)
scale(biquad,pnorm,Name,Value)

Description

scale(biquad) scales the dsp.BiquadFilter System object™, biquad, using peak magnitude response scaling (L-infinity, 'Linf'). This scaling reduces the possibility of overflows when your filter biquad operates in fixed-point arithmetic mode.

biquadnew = scale(biquad) generates a new filter System object, biquadnew, with scaled second-order sections. The original filter System object, biquad, is not changed.

scale(biquad,pnorm) specifies the norm used to scale the filter. The variable pnorm can be either a discrete-time-domain norm or a frequency-domain norm. Valid time-domain norms are 'l1', 'l2', and 'linf'. Valid frequency-domain norms are 'L1', 'L2', and 'Linf'. Note that L2-norm is equal to l2-norm (Parseval's theorem) but the same is not true for other norms.

The different norms can be ordered in terms of how stringent they are as follows: 'l1' >= 'Linf' >= 'L2' = 'l2' >= 'L1' >= 'linf'.

Using the most stringent scaling, 'l1', the filter is the least prone to overflow, but also has the worst signal-to-noise ratio. Linf-scaling is the most commonly used scaling in practice.

scale(biquad,pnorm,opts) uses an options object to specify the optional scaling parameters in lieu of specifying parameter-value pairs. The opts object can be created using the scaleopts function: opts = scaleopts(biquad).

example

scale(biquad,pnorm,Name,Value) specifies optional scaling parameters via by one or more Name,Value pair arguments.

Examples

collapse all

Demonstrate the Linf-norm scaling of a biquad filter using the scale function.

Fs = 8000; Fcutoff = 2000;
[z,p,k] = butter(10,Fcutoff/(Fs/2)); [s,g] = zp2sos(z,p,k);
biquad = dsp.BiquadFilter('Structure', 'Direct form I', ...
    'SOSMatrix', s,'ScaleValues', g);
scale(biquad,'linf','scalevalueconstraint','none','maxscalevalue',2)

Input Arguments

collapse all

Input filter, specified as a dsp.BiquadFilter System object.

Example: biquad = dsp.BiquadFilter('Structure', 'Direct form I', ...'SOSMatrix', s,'ScaleValues', g);

Valid time-domain norm values for pnorm are 'l1', 'l2', and 'linf'. Valid frequency-domain norm values are 'L1', 'L2', and 'Linf' . The 'L2' norm is equal to the 'l2' norm (by Parseval's theorem), but this equivalency does not hold for other norms — 'l1' is not the same as 'L1' and 'Linf' is not the same as 'linf'.

Filter norms can be ordered in terms of how stringent they are, as follows from most stringent to least: 'l1', 'Linf', 'l2' ('L2'), 'linf'. Using 'l1', the most stringent scaling, produces a filter that is least likely to overflow, but has the worst signal-to-noise ratio performance. The default scaling 'Linf' (default) is the most commonly used scaling norm.

You can create an fdopts.sosscaling object, opts, using the scaleopts function.

The following table lists the properties of opts:

Parameter

Default

Description and Valid Value

sosReorder

'auto'

Reorder section prior to scaling.

Valid options are 'auto' (default), 'none', 'up', 'down', 'lowpass', 'highpass', 'bandpass', and 'bandstop'.

MaxNumerator

2

Maximum allowed value for numerator coefficients.

NumeratorConstraint

'none'

Specifies whether and how to constrain numerator coefficient values. Options are 'none' (default), 'unit', 'normalize', and 'po2'.

OverflowMode

'wrap'

Sets the way the filter handles arithmetic overflow situations during scaling. Valid options are 'wrap' (default), 'saturate', and 'satall'.

ScaleValueConstraint

'unit'

Specify whether to constrain the filter scale values, and how to constrain them. Valid options are 'unit' (default), 'none', and 'po2'.

MaxScaleValue

'Not used'

Maximum allowed scale values. The filter applies the MaxScaleValue limit only when you set ScaleValueConstraint to a value other than unit. Setting MaxScaleValue to a numerical value automatically changes the ScaleValueConstraint setting to none.

Example: opts = scaleopts(biquad)

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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: [z,p,k] = butter(10,2000/(8000/2)); [s,g] = zp2sos(z,p,k); biquad = dsp.BiquadFilter('Structure','Direct form I','SOSMatrix',s,'ScaleValues',g); scale(biquad,'linf','scalevalueconstraint','none','maxscalevalue',2)

Arithmetic type used during analysis, specified as one of 'double', 'single', or 'fixed'. The scale method assumes a double precision filter when the arithmetic input is not specified and 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. If 'Arithmetic' is 'double' or 'single', the default values are used for all scaling options that are not specified as an input to the scale function. If 'Arithmetic' is 'fixed', the values used for the scaling options are set according to the settings in the filter System object, biquad. However, if a scaling option is specified that differs from the settings in biquad, this option is used for scaling purposes but does not change the setting in biquad. For example, if you do not specify the 'OverflowMode' scaling option, the scale method assumes that the 'OverflowMode' is equal to the value in the OverflowAction property of the System object, biquad. If you do specify an 'OverflowMode' scaling option, then the scale function uses this overflow mode value regardless of the value in the OverflowAction property of the System object.

Reorder filter sections prior to applying scaling. Possible options:

  • 'auto'

  • 'none'

  • 'up'

  • 'down'

  • 'lowpass'

  • 'highpass'

  • 'bandpass'

  • 'bandstop'

Automatic reordering takes effect when biquad is obtained as a result from a design using fdesign. The sections are automatically reordered depending on the response type of the design.

Maximum allowed value for numerator coefficients, specified as a positive scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Method to constrain numerator coefficient values, specified as one of the following:

  • 'none'

  • 'normalized'

  • 'po2'

  • 'unit'

Sets the way the filter handles arithmetic overflow situations during scaling. If your device does not have guard bits available, and you are using saturation arithmetic for filtering, use 'satall' instead of 'saturate'. The default is 'wrap'.

Specify whether to constrain the filter scale values, and how to constrain them. Choosing 'unit' for the constraint disables the MaxScaleValue property setting. 'po2' constrains the scale values to be powers of 2, while 'none' removes any constraint on the scale values. 'unit' is the default value.

Maximum allowed scale values. The filter applies the MaxScaleValue limit only when you set ScaleValueConstraint to a value other than unit (the default setting). Setting MaxScaleValue to any numerical value automatically changes the ScaleValueConstraint setting to none.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Scaled biquad filter object, returned as a dsp.BiquadFilter System object. This System object contains scaled second-order sections.

References

[1] Dehner, G.F. “Noise Optimized Digital Filter Design: Tutorial and Some New Aspects.” Signal Processing. Vol. 83, Number 8, 2003, pp. 1565–1582.

Introduced in R2011a