Documentation

Contents

Peak Finder

Determine whether each value of input signal is local minimum or maximum

Library

Signal Operations

dspsigops

Description

The Peak Finder block counts the number of local extrema in each column of the real-valued input signal. The block outputs the number of local extrema at the Cnt port. You can also configure the block to output the extrema indices, the extrema values, and a binary indicator of whether or not the extrema are maxima or minima.

To qualify as an extrema, a point has to be larger (or smaller) than both of its neighboring points. Thus, end points are never considered extrema.

If you select the Output peak indices check box, the Idx port appears on the block. The block outputs the zero-based extrema indices at the Idx port. If you select the Output peak values check box, the Val port appears on the block. The block outputs the extrema values at the Val port. If you select either of these check boxes and set the Peak type(s) to Maxima and Minima, the Pol port also appears on the block. If the signal value is a maximum, the block outputs a 1 at the Pol ("Polarity") port. If the signal value is a minimum, the block outputs a 0 at the Pol port.

Use the Maximum number of peaks to find parameter to specify how many extrema to look for in each input signal. The block stops searching the input signal once this maximum number of extrema has been found.

If you select the Ignore peaks within threshold of neighboring values check box, the block no longer detects low-amplitude peaks. This feature allows the block to ignore noise within a threshold value that you define. Enter a threshold value for the Threshold parameter. Now, the current value is a maximum if (current – previous) > threshold and (current – next) > threshold. The current value is a minimum if (current – previous) < –threshold and (current – next) < –threshold.

Examples

Example 1

Consider the input vector

[9 6 10 3 4 5 0 12]

The table below shows the analysis made by the Peak Finder block. Note that the first and last input signal values are not considered:

Previous, current, and next values

9 6 10

6 10 3

10 3 4

3 4 5

4 5 0

5 0 12

Current value if it is an extremum

6

10

3

5

0

Index of current value if it is an extremum

1

2

3

5

6

Polarity of current value if it is an extremum

0

1

0

1

0

Therefore, for this example the outputs at the block ports are

Cnt: 5

Idx: [1 2 3 5 6]

Val: [6 10 3 5 0]

Pol: [0 1 0 1 0]

Example 2

Note that the Overflow mode parameter can affect the output of the block when the input is fixed point. Consider the following model:

In this model, the settings in the Constant block are

  • Constant value[-1 0.5 -1]

  • Interpret vector parameters as 1–D — not selected

  • Sampling modeSample based

  • Sample time1

  • Output data type<data type expression>

  • ModeFixed point

  • SignSigned

  • ScalingBinary point

  • Word length16

  • Fraction length15

The settings in the Peak Finder blocks are

  • Peak type(s)Maxima

  • Output peak indices — not selected

  • Output peak values — selected

  • Maximum number of peaks to find2

  • Ignore peaks within threshold of neighboring values — selected

  • Threshold0.25

  • Overflow modeWrap for Peak Finder Wrap, Saturate for Peak Finder Saturate

Setting the Overflow mode parameter of the Peak Finder Wrap block to Wrap causes the calculations (current – previous) > threshold and (current – next) > threshold to wrap on overflow, thereby causing the maximum to be missed.

Dialog Box

The Main pane of the Peak Finder block dialog appears as follows.

Peak type(s)

Specify whether you are looking for maxima, minima, or both.

Output peak indices

Select this check box if you want the block to output the extrema indices at the Idx port.

Output peak values

Select this check box if you want the block to output the extrema values at the Val port.

Maximum number of peaks to find

Enter the number of extrema to look for in each input signal. The block stops searching the input signal for extrema once the maximum number of extrema has been found. The value of this parameter must be an integer greater than or equal to one.

Ignore peaks within threshold of neighboring values

Select this check box if you want to eliminate the detection of peaks whose amplitudes are within a specified threshold of neighboring values.

Threshold

Enter your threshold value. This parameter appears if you select the Ignore peaks within threshold of neighboring values check box.

When you select the Ignore peaks within threshold of neighboring values check box, the Data Types pane of the Peak Finder block appears as follows.

Overflow mode

Select the overflow mode to be used when block inputs are fixed point.

Supported Data Types

Port

Supported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Cnt

  • 32-bit unsigned integers

Idx

  • 32-bit unsigned integers

Val

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Pol

  • Boolean

See Also

MaximumDSP System Toolbox
MinimumDSP System Toolbox

Was this topic helpful?