Clear Filters
Clear Filters

FFT and Fourier series formulas from CSV data file

2 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 31 Oct 2023
Moved: Walter Roberson on 31 Oct 2023
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 Comments
Seweryn
Seweryn on 31 Oct 2023
Edited: Seweryn on 31 Oct 2023
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 on 31 Oct 2023
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.

Sign in to comment.

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!