# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# peak2peak

Maximum-to-minimum difference

## Syntax

Y = peak2peak(X)Y = peak2peak(X,DIM)

## Description

Y = peak2peak(X) returns the difference between the maximum and minimum values in X. peak2peak operates along the first nonsingleton dimension of X by default. 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 maximum-to-minimum differences of the columns of X.

Y = peak2peak(X,DIM) computes the maximum-to-minimum differences of X along the dimension, DIM.

## Input Arguments

 X Real- or complex-valued input vector or matrix. By default, peak2peak acts along the first nonsingleton dimension of X. For complex-valued inputs, peak2peak identifies the maximum and minimum in absolute value. peak2peak subtracts the complex number with the minimum modulus from the complex number with the maximum modulus. DIM Dimension for maximum-to-minimum difference. The optional DIM input argument specifies the dimension along which to compute the maximum-to-minimum differences. Default: First nonsingleton dimension

## Output Arguments

 Y Maximum-to-minimum difference. For vectors, Y is a real-valued scalar. For matrices, Y contains the maximum-to-minimum differences computed along the specified dimension, DIM. By default, DIM is the first nonsingleton dimension.

## Examples

collapse all

Compute the maximum-to-minimum difference of a 100 Hz sinusoid sampled at 1 kHz.

t = 0:0.001:1-0.001; x = cos(2*pi*100*t); y = peak2peak(x) 
y = 2 

Compute the maximum-to-minimum difference of a complex exponential with a frequency of rad/sample.

Create a complex exponential with a frequency of rad/sample. Find the peak-to-peak difference.

n = 0:99; x = exp(1j*pi/4*n); y = peak2peak(x) 
y = -1.7071 - 0.7071i 

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 maximum-to-minimum differences of the columns.

t = 0:0.001:1-0.001; x = cos(2*pi*100*t)'*(1:4); y = peak2peak(x) 
y = 2 4 6 8 

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 maximum-to-minimum differences 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 = peak2peak(x,2) 
y = 2 4 6 8 

## References

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