FFT and Fourier series formulas from CSV data file

2 次查看(过去 30 天)
Hi guys, I'm struggling with a problem. I obtained the rms values for ch1 (voltage) and ch2 (current) and performed an FFT analysis in simulink (as you can see in pdf file), but I wonder if I can get the Fourier series formulas for each waveform in Matlab? Values start at line 22 in .csv file (A22:C10021)
I would be delighted to any help.
Kind regards,
Seweryn

采纳的回答

Walter Roberson
Walter Roberson 2023-10-31
移动:Walter Roberson 2023-10-31
filename = 'tek0005.csv';
data = readmatrix(filename, 'HeaderLines', 21);
time = data(:,1);
T = mean(diff(time));
Fs = 1./T;
L = height(time);
freqs = Fs/L*(0:L-1);
ch1 = data(:,2);
ch2 = data(:,3);
F1 = fft(ch1);
F2 = fft(ch2);
tiledlayout('flow');
nexttile();
plot(freqs, abs(F1)); title('ch1');
xlabel("f (Hz)"); ylabel("|fft(ch1)|")
nexttile();
plot(fftshift(abs(F1))); title('shifted ch1');
nexttile();
plot(freqs, abs(F2)); title('ch2');
xlabel("f (Hz)"); ylabel("|fft(ch2)|")
nexttile();
plot(fftshift(abs(F2))); title('shifted ch2');
  2 个评论
Seweryn
Seweryn 2023-10-31
编辑:Seweryn 2023-10-31
Hi @Walter Roberson, thank you so much for your help, I'm also wondering if we can get a trigonometric Fourier series with appropriate coefficients for each waveform? Something like the picture below. Thank you in advance!
Walter Roberson
Walter Roberson 2023-10-31
https://en.m.wikipedia.org/wiki/Euler%27s_formula
now consider exp(i*x + c) where c is real.
Each entry in the fft output is a complex number so using the equivalence you can separate into sin and cos components.
There will be thousands of these components unless you are willing to say that if abs() of a component is less than a tolerance then you want to consider the component to be effectively 0.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by