Main Content

PeakFinderConfiguration

Compute and display the largest calculated peak values on the scope display

Since R2022a

    Description

    Use the PeakFinderConfiguration object to compute and display peaks in the scope. The scope computes and displays peaks for only the portion of the input signal that is currently on display in the scope.

    You can specify the number of peaks you want the scope to display, the minimum height above which you want the scope to detect peaks, the minimum distance between peaks, and label the peaks. You can control the peak finder settings from the scope toolstrip or from the command line. The algorithm defines a peak as a local maximum with lower values present on either side of the peak. It does not consider end points as peaks. For more information on the algorithm, see the findpeaks (Signal Processing Toolbox) function.

    To modify the peak finder settings in the scope interface, click the Measurements tab and enable Peak Finder. Once you enable the Peak Finder, an arrow appears on the plot at each maxima and a Peaks panel appears at the bottom of the scope window.

    Time Scope Toolstrip

    Snapshot showing peak finder measurements in Time Scope toolstrip.

    Creation

    Description

    pkfinder = PeakFinderConfiguration() creates a peak finder configuration object.

    example

    Properties

    expand all

    All properties are tunable.

    Level above which the scope detects peaks, specified as a real scalar.

    Scope Window Use

    On the Measurements tab, select Peak Finder. In the peak finder settings, specify a real scalar in the Min Height box.

    Data Types: double

    Maximum number of peaks to show, specified as a positive integer less than 100.

    Scope Window Use

    On the Measurements tab, select Peak Finder. In the peak finder settings, specify a positive integer less than 100 in the Num Peaks box.

    Data Types: double

    Minimum number of samples between adjacent peaks, specified as a positive integer.

    Scope Window Use

    On the Measurements tab, select Peak Finder. In the peak finder settings, specify a positive integer in the Min Distance box.

    Data Types: double

    Minimum difference in the height of the peak and its neighboring samples, specified as a nonnegative scalar.

    Scope Window Use

    On the Measurements tab, select Peak Finder. In the peak finder settings, specify a nonnegative scalar in the Threshold box.

    Data Types: double

    Label found peaks, specified as true or false. The scope displays the labels (P1, P2, …) above the arrows in the plot.

    Scope Window Use

    On the Measurements tab, select Peak Finder. In the peak finder settings, select Label Peaks.

    Data Types: logical

    Coordinates to display next to the calculated peak value, specified as "x", "y", or "x + y".

    Data Types: char | string

    Enable peak finder measurements, specified as true or false. Set this property to true to enable the peak finder measurements.

    Scope Window Use

    On the Measurements tab, select Peak Finder.

    Data Types: logical

    Examples

    collapse all

    Create a sine wave and view it in the Time Scope. Enable the peak finder programmatically.

    Initialization

    Create the input sine wave using the sin function. Create a timescope MATLAB® object to display the signal. Set the TimeSpan property to 1 second.

    f = 100;
    fs = 1000;
    swv = sin(2.*pi.*f.*(0:1/fs:1-1/fs)).';
    scope = timescope(SampleRate=fs,...
        TimeSpanSource="property", ...
        TimeSpan=1);

    Peaks

    Enable the peak finder and label the peaks. Set the scope to show three peaks and label them.

    scope.PeakFinder.Enabled = true;
    scope.PeakFinder.LabelPeaks = true;
    scope(swv)
    release(scope)

    Version History

    Introduced in R2022a