pe_plotHarmonics

Plot percentage of fundamental magnitude versus harmonic order

Syntax

  • pe_plotHarmonics(loggingNode) example
  • pe_plotHarmonics(loggingNode,valueIdx) example
  • pe_plotHarmonics(loggingNode,valueIdx,tOfInterest) example
  • pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest) example
  • pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest,...
    offsetOfInterest)
    example
  • pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest,...
    offsetOfInterest,nHarmonic)
    example

Description

example

pe_plotHarmonics(loggingNode) plots a bar chart of percentage of fundamental magnitude versus harmonic order of the simscape.logging.Node of an AC or periodic variable. The title of the bar chart includes the fundamental frequency, fundamental peak value, and total harmonic distortion (THD) percentage.

You enter the input arguments in a specific order. The Simscape™ logging node input argument is required. All other input arguments are optional and have default values. You enter [] to use the default value for an optional input argument if you are going to specify a value for a subsequent optional input argument.

The pe_plotHarmonics function uses the pe_getHarmonics function to:

  • Find the points in the ith signal (valueIdx) where the Simscape log crosses a threshold (offsetOfInterest).

  • Use the crossing points to find the required number of periods (nPeriodOfInterest) preceding the specified time (tOfInterest).

  • Calculate the harmonic magnitudes, up to and including the required number of harmonics (nHarmonic).

  • Input the down-selected data to the Goertzel algorithm, which calculates the harmonic magnitudes up to and including the required number of harmonics (nHarmonic).

    Note:   The pe_getHarmonics function uses threshold crossing points to determine the fundamental frequency of the data. If your input data is noisy or crosses the threshold more frequently than half of the fundamental period, filter it before you use the pe_plotHarmonics function to plot it.

The pe_plotHarmonics function then inputs the harmonic orders and harmonic magnitudes to the pe_calculateThdPercent function to calculate the THD.

pe_plotHarmonics(loggingNode,valueIdx) uses the index into value data.

pe_plotHarmonics(loggingNode,valueIdx,tOfInterest) uses the simulation time.

pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest) uses the number of periods of fundamental frequency.

pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest,...
offsetOfInterest)
uses the DC offset.

pe_plotHarmonics(loggingNode,valueIdx,tOfInterest,nPeriodOfInterest,...
offsetOfInterest,nHarmonic)
uses the number of harmonics.

Examples

Plot using default values

This set of function arguments uses the Simscape logging node simlog.Load.V, which contains data from a three-phase voltage. The function will analyze the default signal, which is the first, or a-phase, signal at the final simulation time. The function will use the default values of 12 for the number of periods of the signal, 0V for the signal bias, and 30 for the number of harmonics.

pe_plotHarmonics(simlog.Load.V)

Plot using specified values

This set of function arguments uses the Simscape logging node simlog.Load.V, which contains data from a three-phase voltage. The function will analyze the second, or b-phase, signal at a simulation time of 2.3s, The function will use 10 periods of the signal, which has a bias of 1V. The function will analyze 15 harmonics.

pe_plotHarmonics(simlog.Load.V,2,2.3,10,1,15)

Plot using default and specified values

This set of function arguments uses the Simscape logging node simlog.Load.V, which contains data from a three-phase voltage. The function will analyze the first, or a-phase, signal at a simulation time of 2.3s, The function will the default number (12) of periods of the signal, which has a bias of 1V. The function will analyze the default number (30) of harmonics.

pe_plotHarmonics(simlog.Load.V,[],2.3,[],1)

Input Arguments

expand all

loggingNode — Simscape logging node1-by-1 simscape.logging.Node

Simscape logging node, specified as a 1-by-1 simscape.logging.Node. You create a simscape.logging.Node by running a simulation with Simscape logging enabled. See Enable Data Logging for the Whole Model to learn how to enable data logging.

Example: simlog.Load.V

The Simscape logging node simlog.Load.V contains data from a three-phase voltage.

valueIdx — Index into value data1 (default) | scalar

Index into value data, specified as a scalar. Specifies the ith variable of interest in the Simscape log.

Example: 2

Specify the b-phase, which is the second signal from a three-phase voltage.

Example: []

Use [] to specify the default value of 1. The a-phase, which is the first signal from a three-phase voltage, is the default signal of interest.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

tOfInterest — Simulation timefinal time in Simscape log (default) | scalar

Simulation time of interest for harmonic analysis, specified as a scalar.

Example: 2.3

Specify a 2.3s simulation time.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

nPeriodOfInterest — Number of periods12 (default) | scalar

Number of periods of fundamental frequency to be included in harmonic analysis, specified as a scalar.

Example: 10

Specify 10 periods of the signal.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

offsetOfInterest — DC offset0 (default) | scalar

DC offset in the input signal, specified as a scalar. The function uses this value to find the periods of interest.

Example: 1

Specify a bias of 1V for the signal.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

nHarmonic — Number of harmonics30 (default) | scalar

Number of harmonics to include in analysis, specified as a scalar.

Example: 15

Specify that the number of harmonics to be analyzed is 15.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Was this topic helpful?