You are here : matlabSignal Processingrms

rms() - Signal Processing

```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.```

Syntax

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

Example

```RMS Level of SinusoidOpen This Example
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)

y =

0.7071

RMS Levels of 2-D MatrixOpen This Example
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)'*(1:4);

y = rms(x)

y =

0.7071    1.4142    2.1213    2.8284

RMS Levels of 2-D Matrix Along Specified DimensionOpen This Example
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 = (1:4)'*cos(2*pi*100*t);

y = rms(x,2)

y =

0.7071
1.4142
2.1213
2.8284```