Is this code for fft correct
古いコメントを表示
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 件のコメント
Jon
2023 年 8 月 9 日
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.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!