3.5.2.34 Movrms

Description

The function returns a vector to calculate the root mean square(rms) of adjacent ranges [i-nb, i+nf], for a point i

The root mean square of adjacent ranges at point i is given by

x_{\mathrm{rms}}=\sqrt{ \frac{ \sum_{i-nb}^{i+nf} x_i^2 }{nb+nf+1} }

where nb is the backward offset and nf is the forward offset

Syntax

vector Movrms(vector vx, int back[, int forward, int missing, int mothed])

Parameters

vx

Input data vector used to calculate adjacent rms.

back

Input integer for the offset backward with respect to current row number.

forward

Input integer for the offset forward with respect to current row number. If forward is omitted, it will be set to be equal to back internally

missing (2025b)

Optional. Determine how to deal with the missing value in the adjacent range.
  • missing = 0 omits missing values from the calculation. This is the default value.
  • missing = 1 includes missing values in the calculation, which means, if an adjacent range includes missing its output will be missing;
  • missing = 2 omits missing values from the calculation but keeps missing in the ouput, which means, if a row is missing, its output will be missing.

method (2025b)

Optional. Determine which method to use.
  • method = 0 the fast method, old behavior.
  • method = 1 the robust method sorts data in a special way then applies the sum-divide algorithm.

Return

Return the adjacent RMS vector

Notes: The boundary will be treated with the way below

y_i=\left\{\begin{matrix}
RMS([x_0, x_{i+forward}]), & \textup{if} \; i <= back -1;\\
RMS([x_{i-back}, x_{n-1}]), & \textup{if} \; i > n-1-forward. 
\end{matrix}\right.

Example

//Col(B) will be filled with rms at each point for data within the window [i-2, i+2]
//Col(C) will be filled with rms at each point for data within the window [i, i+2]
for(ii=1;ii<=30;ii++) col(A)[ii] = ii;
col(B)=movrms(col(1),2);
col(C)=movrms(col(1),0, 2);

See Also

Rms, Movavg, Movslope