Root mean square.
g=rms(f)
g=rms(f,'linlog')
g=rms(f,MODE)
SQRT takes the square root of the imat_fnM. NUM must be a scalar. Complex results are produced if F is not positive.
RMS calculates the root mean square value of the supplied imat_fn. For evenly spaced functions the formula used is
rms = sqrt( 1/length(y) * sum(y.^2) );
Note that when F is unevenly spaced, RMS will use the formula based on the formula for a continuous function,
rms = sqrt(1./(x(end)-x(1)) * sum((y.^2).*[0; diff(x)]))
This can cause differences in the RMS value calculated versus an equivalent evenly spaced function.
RMS also supports two frequency-band options for calculating the RMS value, assuming that the abscissa values in the supplied function are the center frequencies of the bands. Please see below for details of how these work.
If the function in F is a frequency domain function and is a spectrum (any type) or frequency response function, RMS will be calculated in one of several ways. The AmplitudeUnits and Normalization attributes become very important. Unfortunately, I-deas and NX do not set these attributes properly, so in this case if the FunctionType is Power Spectral Density and the AmplitudeUnits and Normalization are Unknown, RMS will assume 'RMS' and 'Units squared/Hz'.
If the AmplitudeUnits attribute is 'Peak', the calculated RMS value from the above formulas will be multiplied by 1/sqrt(2). If it is 'Half-Peak', it will be multiplied by sqrt(2).
If the Normalization is 'Units squared/Hz', the RMS is calculated by taking the square root area under the curve. Otherwise, the bandwidth (delta F) is not used in the calculation. For unevenly spaced functions, the trapezoidal rule is used to get the area under the curve. Otherwise, the absolute value of the ordinate values are summed.
RMS values for linear amplitude functions such as spectra and FRF are calculated by taking the square root of the sum of the absolute values of the amplitude squared.
RMS determines whether the frequency domain function is linear or squared by looking at Normalization and OrdNumTypeQual. If either of these attributes contain the word 'squared', or FunctionType is Power Spectral Density, Auto Spectrum, or Cross Spectrum, the units are considered to be squared.
MODE is an optional input string specifying the interpolation type to use. Valid options are 'linlin' (default), 'linlog', 'loglin', and 'loglog'. Two frequency-banded options are also supported. These are 'linband' and 'logband'. Both of these options assume that the frequencies specified in the function abscissa are the center frequencies of each band.
When calculating the RMS using either of the banded options, the ordinate value is assumed to be constant in that band. The only difference in the two is how the bandwidths are computed. These are computed as such:
'linband' | The edges of each frequency band is simply the average of the two adjacent center frequencies. The first bandwidth is the distance between the first and second frequencies, and the last bandwidth is the distance between the last and next-to-last frequencies. |
'logband' | The frequency band edges are simply the geometric average of the two adjacent center frequencies, sqrt(f1*f2). The lowest band edge is calculated as f1*sqrt(f1/f2), where f1 and f2 are the first two center frequencies. The highest and edge is calculated as fn*sqrt(fn/fn-1) where fn-1 and fn are the last two center frequencies. |