Quantcast

Documentation Center

  • Trial Software
  • Product Updates

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

expand all

Peak-to-Peak Difference of Sinusoid

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

Peak-to-Peak Difference of Complex Exponential

Compute the maximum-to-minimum difference 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-to-peak difference.

n = 0:99;
x = exp(1j*pi/4*n);
maxmin = peak2peak(x);

Peak-to-Peak Differences 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 maximum-to-minimum differences 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 = peak2peak(X);

Peak-to-Peak Differences 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 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 = cos(2*pi*100*t);
X = repmat(x,4,1);
amp = (1:4)';
amp = repmat(amp,1,1e3);
X = X.*amp;
Y = peak2peak(X,2);

References

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

See Also

| |

Was this topic helpful?