Engee documentation

peak2peak

The difference between the maximum and minimum.

Library

EngeeDSP

Syntax

Function call

  • y = peak2peak(x) — returns the difference between the maximum and minimum values in x.

  • y = peak2peak(x, dim) — calculates the difference between the maximum and minimum values in x by measurement dim.

Arguments

Input arguments

# x — input signal

+ vector | the matrix | An N-dimensional array

Details

An input signal specified as a vector, matrix, or multidimensional array. For complex-value input signals, peak2peak defines the maximum and minimum of the modulus of a complex quantity. Then peak2peak finds the difference between a complex number with a maximum modulus and a complex number with a minimum modulus.

Типы данных

Float32, Float64

Support for complex numbers

Yes

# dim — the measurement for which the operation is performed

+ scalar

Details

The dimension that the operation is performed on, specified as a positive integer scalar. By default peak2peak works with the first dimension of the array x a dimension greater than 1. For example, if x — row vector or column vector, then y — a real scalar. If x — a matrix of dimension , where Then y — vector is a string of dimension , containing the difference between the maximum and minimum values in the columns x.

Типы данных

Float32, Float64

Output arguments

# y — the difference between the maximum and minimum

+ scalar | the matrix | An N-dimensional array

Details

The difference between the maximum and minimum, returned as a real scalar, matrix, or multidimensional array.

Examples

The difference between the maximum and minimum values in the sine wave

Details

Calculate the difference between the maximum and minimum values for 100 Hz sinusoids with sampling frequency 1 kHz.

import EngeeDSP.Functions: peak2peak

t = range(0, stop=1-0.001, step=0.001)
x = cos.(2*pi*100*t)
y = peak2peak(x)

println("y = ", y)
y = 2.0

The difference between the maximum and minimum values for the complex exponent

Details

Let’s create a complex exponential with a frequency π/4 rad/countdown. Let’s find the difference between the maximum and minimum values.

import EngeeDSP.Functions: peak2peak

n = 0:99
x = exp.(im*pi/4*n)

y = peak2peak(x)
-0.29289321881344843 + 0.7071067811865436im

The difference between the maximum and minimum values for a two-dimensional matrix

Details

Let’s create a matrix in which each column represents a sinusoid with frequency 100 Hz, sampled with frequency 1 kHz, with different amplitudes. The amplitude is equal to the column index.

Calculate the difference between the maximum and minimum values for the columns.

import EngeeDSP.Functions: peak2peak

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

println("y = ", y)
y = [2.0 4.0 6.0 8.0]

The difference between the maximum and minimum values for a two-dimensional matrix along a given dimension

Details

Let’s create a matrix in which each row represents a sinusoid with frequency 100 Hz, sampled with frequency 1 kHz, with different amplitudes. The amplitude is equal to the row index.

Calculate the difference between the maximum and minimum values of the rows, specifying the dimension equal to 2, using the argument dim.

import EngeeDSP.Functions: peak2peak

t = 0:0.001:1-0.001;
x = (1:4) .* cos.(2*pi*100*t)';

y = peak2peak(x, 2)
4×1 Matrix{Float64}:
 2.0
 4.0
 6.0
 8.0

Literature

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