Main Content

dsp.PeakToPeak

(Removed) Peak-to-peak value

dsp.PeakToPeak has been removed. Use the peak2peak function instead. For more information, see Compatibility Considerations.

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?

Creation

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.

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

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

collapse all

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

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

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

References

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

Extended Capabilities

Version History

Introduced in R2012a

expand all

R2023a: dsp.PeakToPeak System object has been removed

The dsp.PeakToPeak System object has been removed. Use the peak2peak function instead.

Update Code

This table shows how to update existing code to use the peak2peak function.

Discouraged UsageRecommended Replacement

Peak-to-Peak Value of Vector Input

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

     9

Peak-to-Peak Value of Matrix Input

Set the Dimension property of the object to 'All' to compute the peak-to-peak values across both dimensions.

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

     15

Peak-to-Peak Value of Vector Input

yfn = peak2peak(in)
yfn = 1×1

     9

Peak-to-Peak Value of Matrix Input

yfn = peak2peak(in,'all')
yfn = 1×1

     15

See Also

Functions

Objects