THD calculation using MATLAB
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello,
I'm a novice in using MATLAB. I want to calculate THD value from my experimental data using MATLAB. I have 10,001 data points, sampling frequency is 100kHz and fundamental frequency is 50 Hz (I'm not in USA). Below is my code. Could you please check that my code is correct or not ?
>> data = importdata('sample_1.xlsx'); % 10,001 data points, sampling rate = 100kHz
>> spect = fft(data)/10001; % frequency of each element = 0, 10, 20, 30,...Hz (100kHz/10,001 data)
>> harmonic = abs(spect(11:5:201)); % here, fundamental = 50 Hz so, frequency 100, 150, 200,....,2000 Hz correspond to 11th, 16th, 21st,....,201st element of 'spect' and 'harmonic' has 39 elements
>> harmonic_sqr = harmonic.^2; % square each element
>> THD = sqrt(sum(harmonic_sqr(1:39)))/abs(spect(6))*100 % 50 Hz corresponds to 6th element of 'spect'
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!