rssq
The root of the sum of squares.
| Library |
|
Arguments
Input arguments
# x — input signal
+
vector | the matrix | N-dimensional array
Details
An input signal specified as a vector, matrix, or multidimensional array.
| Типы данных |
|
| Support for complex numbers |
Yes |
# dim — the measurement by which the operation is performed
+
scalar
Details
The dimension on which the operation is performed, specified as a positive integer scalar.
| Типы данных |
|
Output arguments
# y is the root of the sum of squares
+
scalar | vector | the matrix | N-dimensional array
Details
The root of the sum of squares returned as a real scalar, vector, matrix, or multidimensional array.
Examples
The root of the sum of the squares of the sine wave
Details
Calculate the root of the sum of the squares of the sine wave frequency 100 Hz, sampled with frequency 1 kHz.
import EngeeDSP.Functions: rssq
t = range(0, stop=1-0.001, step=0.001)
x = cos.(2*pi*100*t)
y = rssq(x)
println("y = ", y)
y = 22.360679774997898
The root of the sum of squares of a two-dimensional matrix
Details
Let’s create a matrix in which each column represents a sine wave with a frequency 100 Hz, sampled with frequency 1 kHz, with different amplitudes. The amplitude is equal to the column index.
Calculate the root of the sum of the squares of each column.
import EngeeDSP.Functions: rssq
t = 0:0.001:1-0.001
x = cos.(2*pi*100*t) .* (1:4)'
y = rssq(x)
println("y = ", y)
y = [22.360679774997898 44.721359549995796 67.0820393249937 89.44271909999159]
The root of the sum of squares of a two-dimensional matrix along a given dimension
Details
Let’s create a matrix in which each line is a sine wave with a frequency of 100 Hz, sampled at a frequency of 1 kHz, with different amplitudes. The amplitude is equal to the row index.
Calculate the root of the sum of squares for the rows, specifying the dimension using the argument dim.
import EngeeDSP.Functions: rssq
t = 0:0.001:1-0.001
x = (1:4) .* cos.(2*pi*100*t)'
y = rssq(x, 2)
4×1 Matrix{Float64}:
22.360679774997923
44.721359549995846
67.08203932499363
89.44271909999169