Why is my FFT having many but same peaks?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hafiz Ahmad
am 28 Mär. 2018
Beantwortet: Walter Roberson
am 28 Mär. 2018
I have a signal that I need to analyze and determine the noise. The signal is a collection of 4007 data. I extracted 1 out of the 4007 data and obtained this result:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171619/image.jpeg)
This is how the FFT looks like with just 1 point of the data. This is the code that I used:
signal = importdata('ascan.txt');
Fs = 3490;
Fn = Fs/2;
L = length(signal); % Signal Length
FTsignal = fft(signal)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure(2)
plot(Fv, abs(FTsignal(Iv))*2)
grid
xlabel('frequency (Hz)');
ylabel('magnitude');
title('FFT of Signal');
I used the Nyquist frequency as I expected the symmetrical shape of the result. However when I input the whole signal into the FFT, I got this 2 result:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171620/image.jpeg)
This is using Nyquist frequency, Fn.
As you can see, the number of peaks are the same, and they are the same. I am puzzled as I thought the shape should be symmetrical however, I attained this weird result. Do you know why this is the case?
The sampling frequency is 3490Hz and for this single I used this code:
signal = importdata('charlie.txt');
Fs = 3490;
Fn = Fs/2;
L = length(signal); % Signal Length
FTsignal = fft(signal)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure(2)
plot(Fv, abs(FTsignal(Iv))*2)
grid
xlabel('frequency (Hz)');
ylabel('magnitude');
title('FFT of Signal');
Can anyone point where I went wrong? Thank you for the clarification!
2 Kommentare
Akzeptierte Antwort
Walter Roberson
am 28 Mär. 2018
The data file you provided is 349 x 4007. You indicate that this is a collection of 4007 signals, so each individual signal is 349 x 1 and each column is a different signal. However, you are using length() of the entire array, and length() returns the largest dimension, so length() is 4007 rather than 349.
You are doing the fft of all of the data at the same time, getting a 349 x 4007 array.
You then index that array with a single index, Iv. That invokes linear indexing, so even though Iv is larger than 349, it just goes ahead and pulls data from multiple columns.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!