i try to calculate the THD of a current signal in percent. This is my code
thd_db = thd(ac_current_a.data);
thd_percent = 100*(10^(thd_db/20));
The result of the attached data is 0.88%. But when i analyze the signal with the FFT analysis tool of the powergui, the THD is about 12%, which is more realistic.
I think i have to expand my code with some information, i.e. the fundamental frequency, the number of cycles and so on as it must be done in the FFT Tool.
How can i modify my code to get the correct THD?