how do i calculate THD for m- file waveforms(waveforms in sampling) with and suppression of harmonics for comparison
조회 수: 13 (최근 30일)
이전 댓글 표시
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
채택된 답변
Wayne King
2011년 9월 22일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Measurements and Feature Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!