Main Content

DistortionMeasurementsConfiguration

Compute and display harmonic and intermodulation distortion

Since R2023a

    Description

    Use the DistortionMeasurementsConfiguration object to compute and display harmonic and intermodulation distortion.

    You can specify the distortion type, number of harmonics, and label the harmonics. You can control the distortion settings from the Spectrum Analyzer toolstrip or from the command line. The SpectrumAnalyzerBlockConfiguration object supports the DistortionMeasurementsConfiguration object in the command line.

    To modify the distortion settings in the Spectrum Analyzer toolstrip, click the Measurements tab and edit the settings in the Distortion section.

    Snapshot showing distortion measurements.

    Creation

    Description

    distmeas = DistortionMeasurementsConfiguration() creates a distortion measurements configuration object distmeas.

    example

    Properties

    expand all

    All properties are tunable.

    Type of measurement data to display, specified as "harmonic" or "intermodulation".

    Scope Window Use

    Click the Measurements tab on the Spectrum Analyzer toolstrip. In the Distortion section, set Distortion Type to Harmonic or Intermodulation.

    The Measurements tab appears when you select Spectrum in the Scope tab.

    Data Types: char | string

    Number of harmonics to measure, specified as a positive integer less than or equal to 99.

    Dependency

    To enable this property, set Type to "harmonic".

    Scope Window Use

    Click the Measurements tab on the Spectrum Analyzer toolstrip. In the Distortion section, set Num Harmonics to a positive integer less than or equal to 99.

    The Measurements tab appears when you select Spectrum in the Scope tab.

    Data Types: double

    Label harmonics (for harmonic distortion) and frequencies (for intermodulation distortion), specified as true or false.

    Scope Window Use

    Click the Measurements tab on the Spectrum Analyzer toolstrip. In the Distortion section, select Label Harmonics.

    The Measurements tab appears when you select Spectrum in the Scope tab.

    Data Types: logical

    Enable distortion measurements, specified as true or false.

    Scope Window Use

    Click the Measurements tab on the Spectrum Analyzer toolstrip. In the Distortion section, select Distortion.

    The Measurements tab appears when you select Spectrum in the Scope tab.

    Data Types: logical

    Examples

    collapse all

    Open and run the water hammer model.

    open_system('WaterHammerEffect')
    sim('WaterHammerEffect')
    

    The Spectrum Analyzer in this model shows the power spectrum of the water pressure in the pipe. For more details on this model, see the Water Hammer Effect example.

    You can obtain or modify the peak, cursor, and distortion measurements in the spectrum programmatically by enabling these properties in the SpectrumAnalyzerConfiguration object.

    • PeakFinder

    • CursorMeasurements

    • DistortionMeasurements

    Access the configuration properties of the Spectrum Analyzer block using the get_param function.

    sablock = 'WaterHammerEffect/Spectrum Analyzer';
    cfg = get_param(sablock,'ScopeConfiguration');
    

    To enable these measurements, set the Enabled property to true.

    cfg.CursorMeasurements.Enabled = true;
    cfg.PeakFinder.Enabled = true;
    cfg.DistortionMeasurements.Enabled = true;
    

    You can now modify these measurements programmatically. As an example, display the first five peaks in the spectrum display. By default, the spectrum shows only three peaks. To modify the number of peaks it shows, change NumPeaks to 5. You can even label the peaks using the LabelPeaks property and control the minimum distance between adjacent peaks using the MinDistance property. The changes you make to these properties update the spectra accordingly.

    cfg.PeakFinder.NumPeaks = 5;
    

    Version History

    Introduced in R2023a