Is this code for fft correct
Mostrar comentarios más antiguos
I have the following code for FFT. But I can't tell if its correct or not. Is the code correct?
%: Read the excel file using readtable function
rawTable = readtable('DS0009A.CSV','PreserveVariableNames',true);
X=rawTable{:,1};
Y=rawTable{:,2};
figure
plot(X,Y)
Fs=1000;
y= rawTable{:,2};
F=fft(y);
l=length(y);
p2=abs(F/l);
p1 = p2(1:l/2+1);
p1(2:end-1) = 2*p1(2:end-1);
f = Fs*(0:(l/2))/l;
figure
plot(f,p1)
xlim([0 5])
1 comentario
Jon
el 9 de Ag. de 2023
You will need to attach your data file if you want someone to be able to try running your code.
There are very complete examples for using fft in the MATLAB documentation, type doc fft on your command line or Google matlab fft
If you are not confident using the fft, I suggest making a signal where you know what the expected results are. For example make a signal that is a sum of a few sin waves at different frequencies and amplitudes, and then try fft on that signal.
Respuestas (0)
Categorías
Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!