Compute the moving RMS of a noisy square wave signal using the Moving RMS block. Use the sliding window method with a window length of 20 samples and the exponential weighting method with a forgetting factor of 0.8 and 0.99. For more details on these two methods, see Sliding Window Method and Exponential Weighting Method.
Generate a noisy square wave signal. Apply the sliding window method and the exponential weighting method on this signal. View the output in the Time Scope.
This example compares the performance of the sliding window method with the exponential weighting method. When the signal changes rapidly as in this example, use a smaller sliding window and a lower forgetting factor. When the forgetting factor is low, past data have lesser impact on the current average. This makes the transient sharper, but the signal in general contains more noise.