rms
The RMS value.
| Library |
|
Syntax
Function call
-
y = rms(x)— returns the RMS value of the input signalx.-
If
x— the matrix, theny— a row vector containing the root-mean-square value for each column. -
If
x— a multidimensional array, thenycontains the RMS value calculated from the first dimension of the array, the size of which is not equal to1. Sizeyin this dimension is equal to1, while the dimensions of all other dimensions remain the same as those ofx.
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.
| Типы данных |
|
| 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 :
# 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 valuesNaNinxwhen calculating the RMS value. If any element is in the working dimension —NaN, then the corresponding elements iny—NaN. Values"includemissing"and"includenan"they behave the same way. -
"omitmissing"or"omitnan"— the function ignores the valuesNaNinxwhen calculating the RMS value. If all the elements are in the working dimension —NaN, then the corresponding elements iny—NaN. 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