Main Content

Total Harmonic Distortion

Total harmonic distortion measurement

Since R2019b

  • Total Harmonic Distortion block

Simscape / Electrical / Control / Measurements


The Total Harmonic Distortion block calculates the total harmonic distortion (THD) percentage using these equations:

M=harmonic magnitude2,




  • Mi is the root mean squared (RMS) value of the harmonic magnitude that corresponds to the ith harmonic order.

  • M is VRMS or IRMS.

  • i=2nMi2 is the sum of all harmonic components.



expand all

Harmonic magnitude.

Data Types: single | double


expand all

Total harmonic distortion as a percentage.

Data Types: single | double


expand all

Fundamental frequency, in Hz.

Time between consecutive block executions. During execution, the block produces outputs and, if appropriate, updates its internal state. For more information, see What Is Sample Time? and Specify Sample Time.

For inherited discrete-time operation, specify -1. For discrete-time operation, specify a positive integer. For continuous-time operation, specify 0.

To improve accuracy, set this value at least 10 times smaller than the Time constant parameter.


If this block is in a masked subsystem, or another variant subsystem that allows either continuous or discrete operation, promote the sample time parameter to ensure correct switching between the continuous and discrete implementations of the block. For more information, see Promote Block Parameters on a Mask.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2019b