Need Help with FFT Analysis and Power Factor Calculation in MATLAB
10 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I have a CSV file with two columns: "t" (time) and "i(t)" (current). I want to perform Fast Fourier Transform (FFT) analysis on the "i(t)" data to calculate the Total Harmonic Distortion (THD) and obtain information about power factor components, including displacement power factor and distortion power factor.
Here's what I need assistance with:
1. How can I read the CSV data in MATLAB with the "t" and "i(t)" column headers?
2. Calculate the FFT of the "i(t)" current data.
3. Determine the fundamental frequency and compute THD for the current signal.
4. Calculate the Displacement Power Factor (DPF) and Distortion Power Factor (DPFd).
I would appreciate any guidance or code snippets to help me achieve this analysis in MATLAB. Thank you in advance for your help!
Best regards.
0 件のコメント
回答 (1 件)
Chunru
2023 年 11 月 14 日
Here is the work flow:
1.Read the CSV data in MATLAB with the "t" and "i(t)" column header as a table
x = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1537480/data.csv", "VariableNamingRule", "preserve")
2. Calculate the FFT
Plot the data
figure
plot(x.t, x.("i(t)"))
Since your data is not uniformly sampled, we need an interpolation
ts = diff(x.t(1:2)); % sampling time based on 1st two points (adjust this if necessary)
t = x.t(1):ts:x.t(end); % uniform time points
t0 = x.t;
y0 = x.("i(t)");
% t0 need to be unique
[tu, ia] = unique(t0);
yu = y0(ia);
y = interp1(tu, yu, t); % interplate the data
hold on
plot(t, y);
legend("original", "interp")
3. Determine the fundamental frequency and compute THD for the current signal.
p = 20*log10(abs(fft(y))); % log scale in dB
figure
f = (0:length(p)-1)/ts;
plot(f, p);
xlim(f([1 50])); % zoom in first 0 50 bins
% find the peak
[pmax, imax] = max(p);
hold on
plot(f(imax), p(imax), 'r*')
% Harmonic freq
f(imax)
4. Calculate the Displacement Power Factor (DPF) and Distortion Power Factor (DPFd).
Try out the rest with the definition of THD, DPF and DPFd
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!