You are here : matlabSignal Processingpeak2rms

peak2rms() - Signal Processing

```Y = peak2rms(X) returns
the ratio of the largest absolute value in X to
the root-mean-square (RMS) value of X. peak2rms operates
along the first nonsingleton dimension of X.
For example, if X is a row or column vector, Y is
a real-valued scalar. If Y is an N-by-M matrix
with N > 1, Y is
a 1-by-M row vector containing the peak-magnitude-to-RMS
levels of the columns of Y.Y = peak2rms(X,DIM) computes
the peak-magnitude-to-RMS level of X along the
dimension, DIM.```

Syntax

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

Example

```Peak-Magnitude-to-RMS Ratio of SinusoidOpen This Example
Compute the peak-magnitude-to-RMS ratio of a 100 Hz sinusoid sampled at 1 kHz.
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t);

y = peak2rms(x)

y =

1.4142

Peak-Magnitude-to-RMS Ratio of Complex ExponentialOpen This Example
Compute the peak-magnitude-to-RMS ratio of a complex exponential with a frequency of
Create a complex exponential with a frequency of
rad/sample. Find the peak-magnitude-to-RMS ratio.n = 0:99;
x = exp(1j*pi/4*n);

y = peak2rms(x)

y =

1

Peak-Magnitude-to-RMS Ratios 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 peak-magnitude-to-RMS ratios of the columns.t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)'*(1:4);

y = peak2rms(x)

y =

1.4142    1.4142    1.4142    1.4142

Peak-Magnitude-to-RMS Ratios 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 = peak2rms(x,2)

y =

1.4142
1.4142
1.4142
1.4142```