peak2peak
Maximum-to-minimum difference
Description
Examples
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)
y = 2
Peak-to-Peak Difference of Complex Exponential
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 = 0.0000e+00 + 1.1034e-15i
Peak-to-Peak Differences of 2-D Matrix
Create a matrix in which 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 = 1×4
2 4 6 8
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 = (1:4)'*cos(2*pi*100*t); y = peak2peak(x,2)
y = 4×1
2
4
6
8
Input Arguments
x
— Input array
vector | matrix | N-D array
Input signal, specified as a vector, matrix, or N-D array. For
complex-valued inputs, peak2peak
identifies the maximum and minimum
in complex magnitude. peak2peak
then subtracts the complex number
with the minimum modulus from the complex number with the maximum modulus.
Example: sin(2*pi*(0:255)/4)
specifies a sinusoid as a row
vector.
Example: sin(2*pi*[0.1;0.3]*(0:39))'
specifies a two-channel
sinusoid.
Data Types: double
| single
Complex Number Support: Yes
dim
— Dimension to operate along
positive integer scalar
Dimension to operate along, specified as a positive integer scalar. By default,
peak2peak
operates along the first array dimension of
x
with size greater than 1. For example, if
x
is a row or column vector, y
is a
real-valued scalar. If x
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
.
Data Types: double
| single
Output Arguments
y
— Maximum-to-minimum difference
scalar | vector | matrix | N-D array
Maximum-to-minimum difference, returned as a real-valued scalar, vector, matrix, or N-D array.
References
[1] IEEE® Standard on Transitions, Pulses, and Related Waveforms, IEEE Standard 181, 2003.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
The
peak2peak
function fully supports tall arrays. For more information,
see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2012a
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)