Main Content

Compute Moving RMS of Noisy Step Signal

Compute the moving RMS of a noisy square wave signal using the Moving RMS block. Use the sliding window method with a hop size $(window length - overlap length)$ of 5 and 1, and the exponential weighting method with a forgetting factor of 0.9 and 0.99. Compare the output of these two methods. For more details on these methods, see Sliding Window Method and Exponential Weighting Method.

Open and Run the Model

The Pulse Generator (Simulink) block generates a square pulse input signal of 512 samples in width. The Switch (Simulink) block varies the amplitude of the signal between 1.5 and 0.5. Add zero-mean white Gaussian noise with a variance of 0.001 to the square pulse. The frame length of the input signal is 512 samples.

Compute the moving RMS of this signal across each frame using four Moving RMS blocks. In the first two Moving RMS blocks that use the sliding window method, the window length is set to 100 and the overlap length is set to 95 and 99, respectively, resulting in a hop size of 5 and 1. In the last two Moving RMS blocks that use the exponential weighting method, the forgetting factor is set to 0.9 and 0.99, respectively. View and compare the outputs in the Time Scope.

Compare Moving RMS Outputs

In the sliding window Moving RMS blocks, when you select the Allow arbitrary frame length for fixed-size input signals parameter, the dimensions of the moving RMS output change based on the hop size. If the input is $m-by-n$, then the output has an upper bound size of $ceil(m/hop size)-by-n$. For more details, see Moving RMS.

The last two blocks use the exponential weighting method. In the exponential weighting method, when the signal changes rapidly as in this example, use a lower forgetting factor. When the forgetting factor is low, past data has a lower impact on the current RMS output. This makes the transient sharper even though the output contains more noise. You can see this behavior in the Time Scope when you compare the moving RMS outputs for the forgetting factors 0.9 and 0.99.

See Also

Blocks

Related Topics