Computes the Total Harmonic Distortion (THD) of a signal

function [ THD, ph, amp ] = compute_THD( t,x, freq )

Written by Dr. Yoash Levron

February 2013.

Computes the Total-Harmonic-Distortion (THD)

of a signal x(t). The amplitude and phase of the basic harmonic are also computed. These values are typically useful in power systems, audio signal processing, and other related fields.

The function computes the basic harmonic

of the signal, in the form:

x(t) = amp*cos(w*t - ph) + (higher Harmonics)

where : w = 2*pi*freq

so 'amp' and 'ph' are the phase and amplitude

of the basic harmonic.

DC offset does not affect THD.

inputs:

t - [sec] time vector. (should be periodical with basic harmonic 'freq')

x - signal vector.

freq - [Hz] frequency of the basic harmonic.

outputs:

THD - total harmonic distortion (the scale is 1 = 100%).

ph - [rad] phase of the basic harmonic.

amp - Amplitude of the basic harmonic.

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐