ee_getHarmonics
Return harmonic orders, magnitudes, and fundamental frequency
Syntax
Description
[
calculates the harmonic orders, magnitudes, and fundamental frequency of a
harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_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 ee_plotHarmonics
function to obtain a bar chart from the
same input arguments. You can use the outputs of this function as inputs to the
ee_calculateThdPercent
function to calculate the total
harmonic distortion (THD) percentage.
[
uses
the index into value data.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_getHarmonics(loggingNode
,valueIdx
)
[
uses the simulation time.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_getHarmonics(loggingNode
,valueIdx
,tOfInterest
)
[
uses the number of periods of fundamental frequency.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
)
[
uses the DC offset.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
,...
offsetOfInterest
)
[
uses the number of harmonics.harmonicOrder
,harmonicMagnitude
,fundamentalFrequency
]
=...
ee_getHarmonics(loggingNode
,valueIdx
,tOfInterest
,nPeriodOfInterest
,...
offsetOfInterest
,nHarmonic
)
Examples
Analyze Using Default Values
This set of function arguments uses the Simscape logging node
simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I
,
which contains data from a three-phase current. 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.
openExample("simscapeelectrical/SixPulseHarmonicsExample") sim('SixPulseHarmonics') [~,harmonicMagnitude,~]= ee_getHarmonics(simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I); %harmonicMagnitude stores the peak values of the harmonics. To get the RMS values, divide by sqrt(2) harmonicMagnitude./sqrt(2)
ans = 1.0e+03 * Columns 1 through 14 0.0000 1.3759 0.0000 0.0000 0.0000 0.1548 0.0000 0.0748 0.0000 0.0000 0.0000 0.0602 0.0000 0.0407 Columns 15 through 28 0.0000 0.0000 0.0000 0.0357 0.0000 0.0266 0.0000 0.0000 0.0000 0.0239 0.0000 0.0187 0.0000 0.0000 Columns 29 through 31 0.0000 0.0170 0.0000
Analyze Using Specified Values
This set of function arguments uses the Simscape logging node
simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I
,
which contains data from a three-phase current. 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, assuming a bias of
1
V. The function analyzes 15
harmonics.
openExample("simscapeelectrical/SixPulseHarmonicsExample") sim('SixPulseHarmonics') [~,harmonicMagnitude,~]= ee_getHarmonics(simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I,2,0.5,10,1,15); %harmonicMagnitude stores the peak values of the harmonics. To get the RMS values, divide by sqrt(2) harmonicMagnitude./sqrt(2)
ans = 1.0e+03 * Columns 1 through 15 0.0000 1.3761 0.0008 0.0005 0.0006 0.1544 0.0000 0.0748 0.0003 0.0002 0.0003 0.0599 0.0001 0.0407 0.0004 Column 16 0.0003
Analyze Using Default and Specified Values
This set of function arguments uses the Simscape logging node
simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I
,
which contains data from a three-phase current. 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, assuming a bias of
1
V. The function analyzes the default number,
30
, of harmonics.
openExample("simscapeelectrical/SixPulseHarmonicsExample") sim('SixPulseHarmonics') [~,harmonicMagnitude,~]= ee_getHarmonics(simlog_SixPulseHarmonics.Sensing_current.Current_Sensor.I,[],0.5,[],1); %harmonicMagnitude stores the peak values of the harmonics. To get the RMS values, divide by sqrt(2) harmonicMagnitude./sqrt(2)
ans = 1.0e+03 * Columns 1 through 15 0.0000 1.3759 0.0000 0.0000 0.0000 0.1548 0.0000 0.0748 0.0000 0.0000 0.0000 0.0602 0.0000 0.0407 0.0000 Columns 16 through 30 0.0000 0.0000 0.0357 0.0000 0.0266 0.0000 0.0000 0.0000 0.0239 0.0000 0.0187 0.0000 0.0000 0.0000 0.0170 Column 31 0.0000
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.
Version History
Introduced in R2014a