This Mathcad file demonstrates how to do a "sliding" root mean square (RMS) on a waveform by formula.
Step 1: Define sampling frequency (multiple of 2) and build a waveform with DC offset.
N samples per cycle
C cycles of fundamental
Amplitudes, phase angles, and harmonic numbers of component frequencies.
Step 2: Perform the sliding window RMS calculation.
Russell W. Patterson, P.E.
Manager, System Protection & Analysis
Tennessee Valley Authority
rwpatterson@tva.gov