Main Content

PeakFinderConfiguration

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

    Description

    Use the PeakFinderConfiguration object to compute and display peaks in the scope. The scope computes and shows peaks from 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 in the Peaks section. 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

    example

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

    Properties

    expand all

    All properties are tunable.

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

    Scope Window Use

    Click the Measurements tab on the scope toolstrip. In the Peaks section, set Min Height to a real scalar.

    Data Types: double

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

    Scope Window Use

    Click the Measurements tab on the scope toolstrip. In the Peaks section, set Num Peaks to a positive integer less than 100.

    Data Types: double

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

    Scope Window Use

    Click the Measurements tab on the scope toolstrip. In the Peaks section, set Min Distance to a positive integer.

    Data Types: double

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

    Scope Window Use

    Click the Measurements tab on the scope toolstrip. In the Peaks section, set Threshold to a nonnegative scalar.

    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

    Click the Measurements tab on the scope toolstrip. In the Peaks section, 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 peak finder measurements.

    Scope Window Use

    Click the Measurements tab on the scope toolstrip. In the Peaks section, 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