# 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) 
y = 1.4142 

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

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

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 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 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 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 = (1:4)'*cos(2*pi*100*t); y = peak2rms(x,2) 
y = 1.4142 1.4142 1.4142 1.4142 

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