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])

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

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