dsp.PeakToPeak

Peak-to-peak value

Description

The dsp.PeakToPeak System object™ computes the peak-to-peak value of an input.

To obtain the peak-to-peak value:

  1. Create the dsp.PeakToPeak object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

Syntax

ptp = dsp.PeakToPeak
ptp = dsp.PeakToPeak(Name,Value)

Description

example

ptp = dsp.PeakToPeak creates a peak-to-peak System object, ptp, that computes the difference between the maximum and minimum value in an input or a sequence of inputs.

ptp = dsp.PeakToPeak(Name,Value) returns a peak-to-peak System object with each specified property set to the specified value. Enclose each property name in single quotes. Unspecified properties have default values.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

Set this property to true to enable the calculation of the peak-to-peak difference over successive calls to the algorithm.

Specify the dimension along which to calculate the peak-to-peak ratio as 'All', 'Row', 'Column', or 'Custom'. If you set this property to 'Custom', specify the dimension using the CustomDimension property.

Dependencies

This property applies when the RunningPeakToPeak property is false.

Specify the dimension as a positive integer along which the peak-to-peak difference is computed. The value of this property cannot exceed the number of dimensions in the input signal.

Dependencies

This property applies when the Dimension property is 'Custom'.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Set this property to true to enable resetting the running peak-to-peak. When the property is set to true, a reset input must be specified to the call of object algorithm to reset the running peak-to-peak difference.

Dependencies

This property applies when the RunningPeakToPeak property is true.

Specify the event to reset the running peak-to-peak as one of 'Rising edge', 'Falling edge', 'Either edge', or 'Non-zero'.

Dependencies

This property applies when the ResetInputPort property is true.

Usage

For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Syntax

y = ptp(x)
y = ptp(x,r)

Description

example

y = ptp(x) computes the peak-to-peak value, y, of the floating-point input vector x.

y = ptp(x,r) computes the peak-to-peak value of the input elements over successive calls to the object algorithm. The object optionally resets its state based on the reset input signal, r, and the value of the ResetCondition property. To enable reset, set both the RunningPeakToPeak and the ResetInputPort properties to true.

Input Arguments

expand all

Data input, specified as a vector or a matrix. If x is a matrix, each column is treated as an independent channel. The peak-to-peak value is computed along each channel.

Data Types: single | double

Reset signal, specified as a scalar value. The reset signal resets the object state based on the reset input signal and the value of the ResetCondition property.

Dependencies

To enable this signal, set both the RunningPeakToPeak and the ResetInputPort properties to true.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Output Arguments

expand all

Peak-to-peak value of the input signal, returned as a scalar, vector, or matrix. If RunningPeakToPeak is set to:

  • false –– The object computes the peak-to-peak value of each input channel. If the input is a column vector, the output is a scalar. If the input is a multichannel signal, the output signal is a 1-by-N vector, where N is the number of input channels.

  • true –– The object computes the running peak-to-peak value of the signal. The size of the output signal matches the size of the input signal.

When the RunningPeakToPeak property is true, y corresponds to the peak-to-peak value of the input elements over successive calls to the object algorithm.

Data Types: single | double

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Determine the peak-to-peak value for a vector input.

in = (1:10)';
ptp = dsp.PeakToPeak;
y = ptp(in)
y = 9

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Determine the peak-to-peak value of a matrix input.

in = magic(4);
ptp = dsp.PeakToPeak;
ptp.Dimension = 'All';
y = ptp(in)
y = 15

References

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

Extended Capabilities

See Also

System Objects

Introduced in R2012a