Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

THD + N Calculation of a sine wave in Matlab

Status
Not open for further replies.

smalandr

Newbie level 4
Joined
Oct 29, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
Hi all,
in order to test various signals from different sound softwares, I am measuring parameters such as THD + N for the rendered files.

However I have come to a critical point of evaluating the results, and those are a bit confusing.

After applying the fft transformation, in linear scale (no dB) I have the spectrum of the signal I need to measure.

I then take half of the samples (symmetric) and square them ^2 .. in order to get the Power of the all harmonics. I am identifying where the fundamental is - actually I let the code do that, and I include some samples before and some after, depending on how many samples are not around zero close to the fundamental - the "bell" around the fundamental. Then it should be the sum of all Power of the signal points apart from the fundamental points - divided by the Power of the points around the fundamental.

Does this sound correct? I am pasting the code, which I hope makes some sense:

[a,b]=max(Sig24);
spectP=(Sig24_nodB(1:2048));
spectP=spectP.^2;

spectP_peak=sum(spectP(b-2:b+2));
allpowers = sum(spectP) ;

num= allpowers - spectP_peak;
den=spectP_peak;
THD_N=(num/den) * 100

Many thanks,
Stef
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top