MATLAB: If I have a periodic function piecewise, I could calculate THD Total Harmonic Distortion for it

code generationsignal processingthd fft

I have a periodic signal, but is built in piecewise, how could I calculate THD for this function?

Best Answer

The Signal Processing Toolbox has a function that will do that for you, thd()
thd() is new in R2013b.