Engee documentation

rms

The RMS value.

Library

EngeeDSP

Syntax

Function call

  • y = rms(x) — returns the RMS value of the input signal x.

    • If x — row vector or column vector, then y — a real scalar.

    • If x — the matrix, then y — a row vector containing the root-mean-square value for each column.

    • If x — a multidimensional array, then y contains the RMS value calculated from the first dimension of the array, the size of which is not equal to 1. Size y in this dimension is equal to 1, while the dimensions of all other dimensions remain the same as those of x.

  • y = rms(x, "all") — returns the RMS value of all the elements in x.

  • y = rms(x, dim) — valid by dimension dim. For example, if x — the matrix, then rms(x, 2) It acts on the elements of each row and returns a column vector containing the RMS value of each row.

  • y = rms(_, nanflag) — also sets how to process values NaN in x for any of the previous syntaxes. For example, rms(x, "omitnan") ignores values NaN when calculating the RMS value. The default function is rms takes into account the values NaN.

Arguments

Input arguments

# x — input signal

+ vector | the matrix | An N-dimensional array

Details

An input signal specified as a vector, matrix, or multidimensional array.

Типы данных

Float32, Float64

Support for complex numbers

Yes

# dim — the measurement for which the operation is performed

+ scalar

Details

The dimension that the operation is performed on, specified as a positive integer scalar. The default function is rms works with the first dimension of the array x a dimension greater than 1.

Argument dim specifies a dimension whose length is reduced to 1. Size size(y, dim) equal to 1, while the dimensions of all other dimensions remain the same as those of x.

Consider the input matrix x size on :

  • y = rms(x, 1) calculates the root-mean-square value of the elements in each column of the matrix x and returns a vector string of the size 1 on .

  • y = rms(x, 2) calculates the RMS value of the elements in each row of the matrix x and returns a column vector of size on 1.

# nanflag — condition for missing value

+ "includemissing" (by default) | "includenan" | "omitmissing" | "omitnan"

Details

The condition for missing a value, set as:

  • "includemissing" or "includenan" — the function takes into account the values NaN in x when calculating the RMS value. If any element is in the working dimension — NaN, then the corresponding elements in yNaN. Values "includemissing" and "includenan" they behave the same way.

  • "omitmissing" or "omitnan" — the function ignores the values NaN in x when calculating the RMS value. If all the elements are in the working dimension — NaN, then the corresponding elements in yNaN. Values "omitmissing" and "omitnan" they behave the same way.

Output arguments

# y — RMS value

+ scalar | vector | the matrix

Details

The root-mean-square value returned as a real scalar, vector, or matrix.

Examples

The root-mean-square value of the vector

Details

Calculate the RMS value of the sine wave.

import EngeeDSP.Functions: rms

t = 0:0.001:1-0.001
x = cos.(2*pi*100*t)
y = rms(x)
0.7071067811865476

The root-mean-square value of the columns of the matrix

Details

Let’s create a matrix and calculate the RMS values of each column.

x = [4 -5 1; 2 3 5; -9 1 7]
y = rms(x)
1×3 Matrix{Float64}:
 5.8023  3.41565  5.0

The RMS value of the rows of the matrix

Details

Let’s create a matrix and calculate the RMS values of each row, specifying a dimension equal to 2.

x = [6 4 23 -3; 9 -10 4 11; 2 8 -5 1]
y = rms(x, 2)
3×1 Matrix{Float64}:
 12.144957801491119
  8.916277250063503
  4.847679857416329

The RMS value minus the missing data

Details

Create a matrix containing the values NaN.

x = [1.77 -0.005 NaN -2.95; NaN 0.34 NaN 0.19]
2×4 Matrix{Float64}:
   1.77  -0.005  NaN  -2.95
 NaN      0.34   NaN   0.19

Calculate the root-mean-square values of the matrix, excluding the values NaN. For matrix columns containing at least one value NaN, the RMS value is calculated from the remaining elements. For columns consisting entirely of NaN, the RMS value will be NaN.

y = rms(x, "omitnan")
1×4 Matrix{Float64}:
 1.77  0.240442  NaN  2.09029

Additional Info

RMS value

Details

The RMS value is defined as

with summation over a given dimension.

Literature

  1. IEEE® Standard on Transitions, Pulses, and Related Waveforms, IEEE Standard 181, 2003.