(To be removed) Identify peak values in input signal
The dsp.PeakFinder
System
object™ counts the number of peak values (maxima, minima, or both) in each column of the
real-valued input signal. To qualify as a peak, a point has to be larger (or smaller) than
both of its neighboring points. The end points are not considered as peak values. The object
can also output the indices and values of the peaks, and a binary array that indicates whether
a peak is a maxima or a minima.
To output the peak indices and peak values, set PeakIndicesOutputPort and PeakValuesOutputPort to true
,
respectively. In addition, you can determine which of the peak values is a maxima or a minima
using the polarity matrix. The polarity matrix is a logical array in which a 1 indicates a
maxima, and a 0 indicates a minima. To view the polarity matrix, set PeakType
to 'Maxima and Minima'
and access the fourth output.
Use the MaximumPeakCount property to specify how many peak values to look for in each input signal. The object stops searching the input signal once this maximum number of peak values has been found.
If you set IgnoreSmallPeaks to true
, the object no
longer detects low amplitude peaks and ignores noise within a threshold value that you define.
In this mode, 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.
The dsp.PeakFinder
System
object will be removed in a future release. To determine the local maxima, use the
findpeaks
function. To determine the local minima, use the islocalmin
function and find the signal values corresponding to the local minima indices that the
function determines. For more details, see Compatibility Considerations.
To determine the peak values in an input signal:
Create the dsp.PeakFinder
object and set its properties.
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).
creates a peak
finder System
object that identifies the peak values (maxima, minima, or both) in an input
signal.pkFind
= dsp.PeakFinder
creates a peak finder System
object with each specified property set to the specified value. Enclose each
property name in single quotes.pkFind
= dsp.PeakFinder(Name,Value
)
returns the number of
peak values (minima, maxima, or both) in the input signal. Each column of the input is
treated as a separate channel.cnt
= pkFind(input)
[
returns the number of peak values, cnt
,idx
] = pkFind(input)cnt
, and peak indices,
idx
, in the input signal.
To access the peak indices output, set the PeakIndicesOutputPort
property to
true
.
pkFind = dsp.PeakFinder('PeakType','Maxima', ... 'PeakIndicesOutputPort',true); ... [cnt,idx] = pkFind(input);
[___,
returns the peak values val
] = pkFind(input)val
in the input signal.
To access the peak values output, set the PeakValuesOutputPort
property to
true
.
pkFind = dsp.PeakFinder('PeakType','Maxima', ... 'PeakValuesOutputPort',true); ... [cnt,idx,val] = pkFind(input);
[___,
returns the peak value polarity pol
] = pkFind(input)pol
in input signal. The polarity is
1
for maxima and 0
for minima.
To access the polarity output, set the PeakType
property to
'Maxima and Minima'
, and the
PeakIndicesOutputPort
property to
true
.
pkFind = dsp.PeakFinder('PeakType','Maxima and Minima', ... 'PeakIndicesOutputPort',true); ... [cnt,idx,val,pol] = pkFind(input);
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)
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 whether each value of an input signal is a local maximum or minimum.
pkFind = dsp.PeakFinder; pkFind.PeakIndicesOutputPort = true; pkFind.PeakValuesOutputPort = true; x1 = [9 6 10 3 4 5 0 12]';
Find the peaks of each input [prev;cur;next]
:
{[9;6;10],[6;10;3],...}
[cnt1, idx1, val1, pol1] = pkFind(x1)
cnt1 = uint32
5
idx1 = 10x1 uint32 column vector
1
2
3
5
6
0
0
0
0
0
val1 = 10×1
6
10
3
5
0
0
0
0
0
0
pol1 = 10x1 logical array
0
1
0
1
0
0
0
0
0
0