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!