-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
Home > Community > FPScript > calculate the true RMS value > Reply To: calculate the true RMS value
February 21, 2013 at 9:13 am
#9273
![Bernhard Kantz](https://www.weisang.com/wp-content/uploads/2016/09/default_avatar.jpg)
Participant
The RMS value is a mean value, for a good estimation it is sufficient to average over enough full periods of the signal.
To compute the RMS over single periods, one can use the FPScript function LevelCrossings() to determine the indices of upward zero crossings as boundaries in the signal to compute one RMS value per period.
// indices of upward zero crossings (with 5 % hysteresis)
Dim idx = LevelCrossings(IA, 0, 0.05 * Range(IA), EVENT_POSITIVE, EVENT_INDEX)
// prepare output datasets in the desired length
Dim rms_y = IA.Y[0L] # Shape(idx[1L,-1L])
Dim rms_x = IA.X[0L] # Shape(idx[1L,-1L])
Dim i_begin, i_end
For Each Row i In idx[1L,-1L] Do
// extract a full period
i_begin = idx
i_end = idx - 1L
// use x (time) of the interval center
rms_x = IA.X[(i_begin + i_end) / 2L]
rms_y = Mean(IA[i_begin, i_end], MEAN_SQUARE)
End
Signal(rms_y, rms_x)