# peak2rms

Peak-magnitude-to-RMS ratio

## Syntax

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

## Description

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

## Input Arguments

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

## Output Arguments

 `Y` Peak-magnitude-to-RMS ratio. For vectors, `Y` is a real-valued scalar. For matrices, `Y` contains the peak-magnitude-to-RMS levels computed along the specified dimension, `DIM`. By default, `DIM` is the first nonsingleton dimension.

## Examples

collapse all

### Peak-magnitude-to-RMS Ratio of Sinusoid

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);```

### Peak-magnitude-to-RMS Ratio of Complex Exponential

Compute the peak-magnitude-to-RMS ratio of a complex exponential with a frequency of π/4 radians/sample.

Create a complex exponential with a frequency of π/4 radians/sample. Find the peak-magnitude-to-RMS ratio.

```n = 0:99; X = exp(1j*pi/4*n); Y = peak2rms(X);```

### Peak-magnitude-to-RMS ratio 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 peak-magnitude-to-RMS ratio 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 = peak2rms(X);```

### Peak-magnitude-to-RMS ratio 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 peak-magnitude-to-RMS ratio 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 = peak2rms(X,2);```

collapse all

### Peak-magnitude-to-RMS Level

The peak-magnitude-to-RMS ratio is

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

where the l-infinity norm and RMS values are computed along the specified dimension.

## References

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