how do i calculate THD for m- file waveforms(waveforms in sampling) with and suppression of harmonics for comparison
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i am doing the project: Analysis of harmonics using wavelet packet transform Actually i am doing the project in MATLAB coding and my project objective is to analyse the signal with disturbance and have to suppress those harmonics which present in that disturbance signal.
so, in order to show the difference by comparing, i need to find Total Harmonic Distortion(THD) for the signal with disturbance and after suppressing those disturbance.
I tried to find THD in MATLAB coding, but yet i did not get any clear result for THD measurement in coding sir. so please give me an idea to measure THD for signal waveform in M-File sir.
thank you sir
0 Kommentare
Akzeptierte Antwort
Wayne King
am 22 Sep. 2011
Hi, You can certainly calculate THD using a spectrum object and the msspectrum method from the Signal Processing Toolbox.
For example:
% Creating a signal
t = linspace(0,1,1e3);
x = cos(2*pi*60*t)+0.05*sin(2*pi*120*t)+0.01*cos(2*pi*180*t);
% Constructing the spectral analysis object
hper = spectrum.periodogram;
% Getting the mean-square spectrum. These are square magnitudes
mspec = msspectrum(hper,x,'Fs',1e3,'NFFT',length(x));
% Creating a data vector with the fundamental and two harmonics
datavec = mspec.Data(61:60:181);
% Calculating the THD
THD = sqrt(sum(datavec(2:end)))/sqrt(datavec(1))
Multiply by 100 to express as a percentage.
%Using fft
xdft = fft(x);
datavec = xdft(61:60:181);
THD = norm(datavec(2:end),2)/norm(datavec(1),2)
The trick is for you to correctly identify the DFT bins that contain your fundamental and harmonics, but that should not be difficult. You can manipulate the NFFT input to fft() or msspectrum() so that your fundamental and harmonics fall on a DFT bin.
Hope that helps,
Wayne
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Measurements and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!