Effacer les filtres
Effacer les filtres

FFT and Fourier series formulas from CSV data file

2 vues (au cours des 30 derniers jours)
Seweryn
Seweryn le 31 Oct 2023
Commenté : Walter Roberson le 31 Oct 2023
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

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Oct 2023
Déplacé(e) : Walter Roberson le 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 commentaires
Seweryn
Seweryn le 31 Oct 2023
Modifié(e) : Seweryn le 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 le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by