# rms

Root-mean-square level

## Syntax

`Y = rms(X)Y = rms(X,DIM)`

## Description

`Y = rms(X)` returns the root-mean-square (RMS) level of the input, `X`. If `X` is a row or column vector, `Y` is a real-valued scalar. For matrices, `Y` contains the RMS levels computed along the first nonsingleton dimension. For example, if `X` is an N-by-M matrix with N>1, `Y` is a 1-by-M row vector containing the RMS levels of the columns of `X`.

`Y = rms(X,DIM)` computes the RMS level of `X` along the dimension, `DIM`.

## Input Arguments

 `X` Real or complex-valued input vector or matrix. By default, `rms` acts along the first nonsingleton dimension of `X`. `DIM` Dimension for RMS levels. The optional `DIM` input argument specifies the dimension along which to compute the RMS levels. Default: First nonsingleton dimension

## Output Arguments

 `Y` Root-mean-square level. For vectors, `Y` is a real-valued scalar. For matrices, `Y` contains the RMS levels computed along the specified dimension `DIM`. By default, `DIM` is the first nonsingleton dimension.

## Examples

collapse all

### RMS Level of Sinusoid

Compute the RMS level of a 100-Hz sinusoid sampled at 1 kHz.

```t = 0:0.001:1-0.001; X = cos(2*pi*100*t); Y = rms(X);```

### RMS Levels of 2-D Matrix

Create a matrix where each column is a 100-Hz sinusoid sampled at 1 kHz with a different amplitude. The amplitude is equal to the column index.

Compute the RMS levels of the columns.

```t = 0:0.001:1-0.001; x = cos(2*pi*100*t)'; X = repmat(x,1,4); amp = 1:4; amp = repmat(amp,1e3,1); X = X.*amp; Y = rms(X);```

### RMS Levels of 2-D Matrix Along Specified Dimension

Create a matrix where each row is a 100-Hz sinusoid sampled at 1 kHz with a different amplitude. The amplitude is equal to the row index.

Compute the RMS levels of the rows specifying the dimension equal to 2 with the `DIM` argument.

```t = 0:0.001:1-0.001; x = cos(2*pi*100*t); X = repmat(x,4,1); amp = (1:4)'; amp = repmat(amp,1,1e3); X = X.*amp; Y = rms(X,2);```

collapse all

### Root-Mean-Square Level

The root-mean-square level of a vector, X, is

${X}_{\text{RMS}}=\sqrt{\frac{1}{N}\sum _{n=1}^{N}|{X}_{n}{|}^{2}}$

with the summation performed along the specified dimension.

## References

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