You are here : matlabSignal Processingpeak2peak

peak2peak() - Signal Processing

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.


Syntax

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


Example

Peak-to-Peak Difference of SinusoidOpen This Example
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

Peak-to-Peak Difference of Complex ExponentialOpen This Example
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

Peak-to-Peak Differences 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 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

Peak-to-Peak Differences 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 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


Output / Return Value


Limitations


Alternatives / See Also


Reference