Determine whether each value of input signal is local minimum or maximum
Signal Operations
dspsigops
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.
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 |
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]
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 mode — Sample
based
Sample time — 1
Output data type — <data type
expression>
Mode — Fixed
point
Sign — Signed
Scaling — Binary
point
Word length — 16
Fraction length — 15
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 find —
2
Ignore peaks within threshold of neighboring values — selected
Threshold — 0.25
Overflow mode —
Wrap
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.
Specify whether you are looking for maxima, minima, or both.
Select this check box if you want the block to output the extrema indices at the Idx port.
Select this check box if you want the block to output the extrema values at the Val port.
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.
Select this check box if you want to eliminate the detection of peaks whose amplitudes are within a specified threshold of neighboring values.
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 Fixed-point operational parameters section appears.
When you select this parameter, the block saturates the result of its
fixed-point operation. When you clear this parameter, the block wraps
the result of its fixed-point operation. For details on
saturate
and wrap
, see overflow
mode for fixed-point operations.
Port | Supported Data Types |
---|---|
Input |
|
Cnt |
|
Idx |
|
Val |
|
Pol |
|