pe_getHarmonics
Return harmonic orders, magnitudes, and fundamental frequency
Syntax
Description
[
calculates the harmonic orders, magnitudes, and fundamental frequency of a
harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
)simscape.logging.Node
of an AC or periodic variable.
The function finds the points in the ith signal (valueIdx) where the Simscape™ log crosses a threshold (offsetOfInterest). It uses the crossing points to find the required number of periods (nPeriodOfInterest) preceding the specified time (tOfInterest). Then it inputs the down-selected data to the Goertzel algorithm, which calculates the harmonic magnitudes up to and including the required number of harmonics (nHarmonic).
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. If you are specifying a value for a subsequent
optional input argument, enter []
to use the default
value for an optional input argument.
You can use the pe_plotHarmonics
function
to obtain a bar chart from the same input arguments. You can use the
outputs of this function as inputs to the pe_calculateThdPercent
function
to calculate the total harmonic distortion (THD) percentage.
[
uses
the index into value data.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
,valueIdx
)
[
uses
the simulation time.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
,valueIdx
,tOfInterest
)
[
uses
the number of periods of fundamental frequency.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
)
[
uses the DC offset.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
,...
offsetOfInterest
)
[
uses the number of harmonics.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
pe_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
,...
offsetOfInterest
,nHarmonic
)
Examples
Analyze Using Default Values
This set of function arguments uses the Simscape logging node
simlog_ee_harmonics_rectifier.AC.N.V
, which contains data
from a three-phase voltage. The function analyzes the default signal, which is
the first, or a-phase, signal at the final simulation time. The function uses
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.
open_system('ee_harmonics_rectifier') sim('ee_harmonics_rectifier') pe_getHarmonics(simlog_ee_harmonics_rectifier.AC.N.V)
ans = Columns 1 through 9 0 1 2 3 4 5 6 7 8 Columns 10 through 18 9 10 11 12 13 14 15 16 17 Columns 19 through 27 18 19 20 21 22 23 24 25 26 Columns 28 through 31 27 28 29 30
Analyze Using Specified Values
This set of function arguments uses the Simscape logging node
simlog_ee_harmonics_rectifier.AC.N.V
, which contains data
from a three-phase voltage. The function analyzes the second, or b-phase, signal
at a simulation time of 0.5
s. The function uses
10
periods of the signal, which has a bias of
1
V. The function analyzes 15
harmonics.
open_system('ee_harmonics_rectifier') sim('ee_harmonics_rectifier') pe_getHarmonics(simlog_ee_harmonics_rectifier.AC.N.V,2,0.5,10,1,15)
ans = Columns 1 through 9 0 1 2 3 4 5 6 7 8 Columns 10 through 16 9 10 11 12 13 14 15
Analyze Using Default and Specified Values
This set of function arguments uses the Simscape logging node
simlog_ee_harmonics_rectifier.AC.N.V
, which contains data
from a three-phase voltage. The function analyzes the first, or a-phase, signal
at a simulation time of 0.5
s. The function uses
12
periods of the signal, which has a bias of
1
V. The function analyzes the default number,
30
, of harmonics.
open_system('ee_harmonics_rectifier') sim('ee_harmonics_rectifier') pe_getHarmonics(simlog_ee_harmonics_rectifier.AC.N.V,[],0.5,[],1)
ans = Columns 1 through 9 0 1 2 3 4 5 6 7 8 Columns 10 through 18 9 10 11 12 13 14 15 16 17 Columns 19 through 27 18 19 20 21 22 23 24 25 26 Columns 28 through 31 27 28 29 30
Input Arguments
Output Arguments
Limitations
This function requires that you use a fixed-step solver for the Simscape Electrical™ Power Systems network that you are analyzing. To specify a fixed-step solver for the physical network, use one of the configuration combinations in the table.
Configuration Combination Global Solver Configuration Local Solver Configuration Global variable-step with local fixed-step Set Type to Variable-step
Enable the options to Use local solver and Use fixed-cost runtime consistency iterations Global and local fixed-step Set Type to Fixed-step
Enable the options to Use local solver and Use fixed-cost runtime consistency iterations Global fixed-step Set Type to Fixed-step
Clear the option to Use local solver This 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 this function to analyze it.
This function requires a minimal number of periods. If the minimal number is not met, the function generates a warning message. To increase the number of periods, use one or both of these methods:
Increase the simulation time.
Increase the switching frequency.