lhlbluesky_lhl
|
in dynamic test code of adc parameter, there is a paragraph to calculate the harmonic distortion, just as follows:
numpt=1024; %sample points spanh=2; %Find harmonic frequencies and power components in the FFT spectrum for har_num=1:10 %Input tones greater than fSAMPLE are aliased back into the spectrum tone=rem((har_num*(fin-1)+1)/numpt,1); if tone>0.5 %Input tones greater than 0.5*fSAMPLE (after aliasing) are reflected tone=1-tone; end Fh=[Fh tone]; %For this procedure to work, ensure the folded back high order harmonics do not overlap %with DC or signal or lower order harmonics har_peak=max(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh)); har_bin=find(spectP(round(tone*numpt-spanh):round(tone*numpt)+spanh)==har_peak) har_bin=har_bin+round(tone*numpt)-spanh-1; Ph=[Ph sum(spectP(har_bin-1:har_bin+1))]; end
1, why 'spanh=2'? can it be other value? 2, about 'har_num*(fin-1)+1' in the second red color line, what is the meaning of 'fin-1' and '+1'? 3, in the third red color line, why 'round(tone*numpt)' is added again, and what is the meaning of '-spanh-1'?
thanks.
|