The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 19th, 2024, 1:31am
Pages: 1
Send Topic Print
confuse about harmonic calculation in matlab (Read 1248 times)
lhlbluesky_lhl
Senior Member
****
Offline



Posts: 115

confuse about harmonic calculation in matlab
Mar 17th, 2013, 5:25am
 
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.
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.