How do you measure total harmonic distortion of shorter duration stimuli?
3 views (last 30 days)
Show older comments
Hi all,
I'm relatively new to the use of MATLAB, but am using it to analyze various acoustic parameters of stimuli I have recorded with and without hearing aids. One of the things I want to measure is total harmonic distortion. I am having problems measuring this with the thd() code from MATLAB for shorter (often for durations of 60 ms, and always for durations of 30 ms), as it reads the wrong fundamental frequency, and therefore the wrong harmonics. What I mean by 'often' for durations of 60 ms is that it sometimes does read them properly for certain signals in one polarity, but not the other, or with different rise and fall times. It also works fine for stimuli with durations of 120ms and above. I know that thd fails when the fundamental frequency is not the largest/highest spectral component of the stimuli, but when I perform an FFT on the signal, the fundamental frequency IS the frequency at which the amplitude is the highest, so I'm confused as to what is wrong.
Here are the few lines I had written to read and obtain the THD value:
averaged_stim_aided=wavread('stimuli.wav'); fs=44100;
r_aided=thd(averaged_stim_aided,fs,5)
percent_thd_aided = 100*(10^(r_aided/20))
%FYI - frequencies (including fundamental) and their power [r,harmpow,harmfreq]=thd(averaged_stim_aided,fs,5)
I tried calculating this manually by reading the magnitude off of the FFT at the fundamental and harmonic frequencies, and using the equation THD = SQRT(SUM(magnitude of harmonics^2))/fundamentalbut my calculated THD is slightly off of the calculated r/percent THD for the stimuli that are measured properly. I am guessing this is because the thd function on MATLAB uses power level, and the magnitude I'm using is in the FFT is pressure level. And thus I'm not sure if my percentage of THD calculation above is correct (i.e. whether the conversion should actually be 100*(10^(r_aided)/10)). I've also tried using Simulink tools for this, but I haven't been able to get it to work without errors, and it seems to run quite slowly.
If anybody could provide feedback, that would be fantastic.
Many thanks.
0 Comments
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!