Main Content

Parameter Smoother

Smooth input parameters using exponential smoothing

Since R2024a

  • Parameter Smoother block icon

Libraries:
DSP System Toolbox / Signal Operations

Description

The Parameter Smoother block gradually updates the input filter parameters until the parameters reach the desired values. The block uses a first-order IIR filter to smooth the parameter. For more information, see Parameter Smoothing.

Examples

expand all

Vary the smoothing time in the Parameter Smoother block and note the smoothing behavior of the parameter in the time scope. The parameter in this example amplifies the audio signal and you can listen to the changes in the audio using the Audio Device Writer block.

Open the parameter_smoothing_time.slx model. The input audio signal has two channels and has a sample rate of 44.1 kHz. The signal is amplified by an amplifying parameter. You can set the value of this parameter between 0 and 25 using a slider. When you change the parameter value, the Parameter Smoother block smooths the parameter based on the Smoothing time constant (seconds) you specify in the block dialog box. In the model, the first Parameter Smoother block uses a smoothing time constant of 2 seconds, while the second Parameter Smoother block uses a smoothing time constant of 0 seconds.

Run the model and change the parameter value around half way through the simulation by setting it to a value between 5 and 20. The smoothed parameter gradually changes without causing any abrupt changes in the quality of the audio signal. However, the parameter with a smoothing time constant of 0 seconds changes abruptly.

Vary the center frequency of the IIR notch filter. Smooth the center frequency value using the Parameter Smoother block. Note the smoothing behavior of the parameter in the Time Scope when you vary the smoothing factor.

Open the notchFilter_smoothingFactor.slx model. The input is a noisy sinusoidal signal with a frequency of 2 kHz, sample rate of 44.1 kHz, and contains 1024 samples per frame. Pass this signal through a Notch-Peak Filter block. The block outputs the Notch filter output and accepts the filter center frequency through the input port Fc. The Sample rate mode parameter of the block is set to Use normalized frequency (0 to 1). This setting enables the block to accept frequency specifications in normalized units.

Vary the center frequency of the notch between 0.1 and 0.8 using the slider. Smooth the variation of the center frequency using the Parameter Smoother block. When the smoothing factor is 0, no smoothing occurs and the parameter changes abruptly. As the smoothing factor approaches 1, smoothing increases and the parameter changes gradually.

Run the model. The center frequency is 0.1. The frequency tone of the sinusoidal signal falls in the notch of the filter attenuating the signal.

When you change the center frequency to 0.8, with a sample rate of 44.1 kHz, the center of the notch moves to 17.64 kHz and the tone is unaffected.

Vary the smoothing factor between 0.1 and 0.9 and notice the time it takes for the center frequency to change to the new value in each of these cases.

When alpha is 0.1, the parameter takes less than 0.1 seconds to change to its new value.

When alpha is 0.9, the parameter takes around 1 second to change to its new value. This is because a higher smoothing factor changes the parameter more gradually.

Ports

Input

expand all

Specify the input parameters to smooth as a scalar, vector, or a matrix. If the value of Number of parameters is greater than 1, then the block labels the input ports as P1, P2, and so on.

This port is unnamed until you select the Specify smoothing factor from input port or Specify smoothing time from input port parameters or you set Number of parameters to a value greater than 1.

Data Types: single | double

Specify the smoothing factor α as a scalar in the range [0, 1). When α = 0, the block does not smooth the parameters. As α approaches 1, smoothing and therefore the number of redesigns increase. For more information on the effect of α on smoothing, see Parameter Smoothing.

Dependencies

To enable this port:

  • Set the Smoothing mode parameter to Smoothing factor.

  • Select the Specify smoothing factor from input port parameter.

Data Types: single | double

Specify the smoothing time τ in seconds as a nonnegative scalar. This value indicates the time it takes for the parameter to change to exp(−T/τ)×current value + (1−exp(−T/τ))×target value, where T is the value you specify in the Sample time (−1 for inherited) parameter. For more information on the effect of τ on smoothing, see Parameter Smoothing.

Dependencies

To enable this port:

  • Set the Smoothing mode parameter to Smoothing time.

  • Select the Specify smoothing time from input port parameter.

Data Types: single | double

Output

expand all

Smoothed value of the parameter, returned as a scalar, vector, or a matrix. This is the instantaneous value of the parameter and it changes until the parameter reaches the target value that you specify at the input port P.

Data Types: single | double

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Specify the number of parameters to smooth as a positive integer. The value of this parameter determines the number of inputs ports on the block.

Specify the mode to use for smoothing as one of these:

  • Smoothing factor –– Specify the smoothing factor in the block dialog box or through the alpha port.

  • Smoothing time –– Specify the smoothing time in the block dialog box or through the tau port.

For more information on these two modes, see Parameter Smoothing.

Select this parameter to specify the smoothing factor from the input port alpha. When you clear this parameter, you can specify the smoothing factor in the block dialog box using the Smoothing factor (between 0 and 1) parameter.

Dependencies

  • To enable this parameter, set the Smoothing mode parameter to Smoothing factor.

Specify the smoothing factor α as a scalar in the range [0, 1). When α = 0, the block does not smooth the parameters. As α approaches 1, smoothing and therefore the number of redesigns increase. For more information on the effect of α on smoothing, see Parameter Smoothing.

Tunable: Yes

Dependencies

To enable this parameter:

  • Set the Smoothing mode parameter to Smoothing factor.

  • Clear the Specify smoothing factor from input port parameter.

Data Types: single | double

Select this parameter to specify the smoothing time from the input port tau. When you clear this parameter, you can specify the smoothing time in the block dialog box using the Smoothing time constant (seconds) parameter.

Dependencies

  • To enable this parameter, set the Smoothing mode parameter to Smoothing time.

Specify the smoothing time τ in seconds as a nonnegative scalar. This value indicates the time it takes for the parameter to change to exp(−T/τ)×current value + (1−exp(−T/τ))×target value, where T is the value you specify in the Sample time (−1 for inherited) parameter. For more information on the effect of τ on smoothing, see Parameter Smoothing.

Tunable: Yes

Dependencies

To enable this parameter:

  • Set the Smoothing mode parameter to Smoothing time.

  • Clear the Specify smoothing time from input port parameter.

Data Types: single | double

Specify the sample time of the input parameters T as -1 (for inherited) or a positive scalar in seconds. This value determines the frequency with which the block updates the instantaneous values of the input parameters until the target value is reached.

Dependencies

To enable this parameter, set the Smoothing mode parameter to Smoothing time.

Data Types: single | double

Specify the type of simulation to run. You can set this parameter to:

  • Interpreted execution –– Simulate model using the MATLAB® interpreter. This option shortens startup time.

  • Code generation –– Simulate model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The C code is reused for subsequent simulations as long as the model does not change. This option requires additional startup time but provides faster subsequent simulations.

Block Characteristics

Data Types

double | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

More About

expand all

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2024a