Why does signal still contain a large number of spikes after FFT

59 ビュー (過去 30 日間)
crixus
crixus 2016 年 10 月 7 日
コメント済み: dpb 2016 年 10 月 13 日
I have perform FFT on my signal but due to the dc offset my amplitude peaks at 0 hz so i use x = x - mean(x) to remove the dc offset before fft but this time round after fft although I can see the difference but it still contains a lot of spikes. It is as if the signal has yet to go through FFT. Is there a reason for this ?

採用された回答

dpb
dpb 2016 年 10 月 7 日
Well, if your original signal is full of a large number of frequency components, the spectrum will be, too. This looks like a few dominants with a large number of what may be sidebands and harmonics/subharmonics. You might see what a dB scale (log) looks like instead of just linear.
What is the signal? Knowing something of the system might let somebody here expound at depth; ya' never knows, but there's a "veritable plethora" of backgrounds/experience.
One issue that could be a problem depending -- was the data collected with analog anti-aliasing filters or some other way to ensure sampling was fast enough to avoid aliasing? If there were components in the original signal higher than or very near the Nyquist, they will fold back into the computed frequency range. If that is the case, once the data are sampled, there's no way to remove that source of contamination.
  13 件のコメント
crixus
crixus 2016 年 10 月 13 日
Hi guys, thanks for the feedback ! truly appreciate it ! what i'm planning to do is to speed up the data saving portion and see what rate is can achieve, if there's a need i'll eliminate one of the board to lessen the data communicate between the microcontroller. otherwise I will just have to buy a real daq :( which i hope not (am a poor part time student)
dpb
dpb 2016 年 10 月 13 日
Remember that for spectral analysis, besides the rate the consistency of that rate is important, too...sampling at 1 kHz a few fractions of a msec owing to OS task-swapping or garbage collection or whatever is a significant error in terms of the sample interval.

サインインしてコメントする。

その他の回答 (2 件)

Image Analyst
Image Analyst 2016 年 10 月 8 日
What are you listening to? It looks like white noise. Is it? If so, I would not be surprised to see basically random energy in any of the wavelengths, which is what I see in your FFT. Like dpb said, we need to know what sound you expect your signal to be, and what you expect the noise to be, to best figure out what kind of filter you need to separate the two.
  7 件のコメント
crixus
crixus 2016 年 10 月 9 日
Actually, this is my first time trying FFT and from the examples that I read, I thought i'm "supposed" to see only one or two spikes within a signal after FFT which is why i thought i'm wrong at this.
dpb
dpb 2016 年 10 月 9 日
The code itself looks ok; it's the data-collection that is the issue as you've now recognized it seems. I'll simply note the "richness" of the FFT is simply dependent upon what the input content is; there are going to be as many peaks as there are discernible frequency components in the input signal; probably the examples in texts you've looked at were selected precisely to illustrate some principles from "clean" systems that had well-defined peaks of given frequencies.
In your particular case here, the system undoubtedly is very rich in energy content from the process and then by drastically under-sampling as your collection process did, that compounded the problem immensely by all of those various actual frequencies getting folded into the spectrum over a number of different times and so it ended up looking essentially as white noise as IA noted.

サインインしてコメントする。


crixus
crixus 2016 年 10 月 8 日
編集済み: crixus 2016 年 10 月 8 日
Hi both, thanks for your replies. The code that i used to perform the FFT is as follow
x = xlsread('test.csv');
x = x(~any(isnan(data1),2),:);
x = x(1:1500,:);
x = x-mean(x);
fs=1000; % sampling freq
xmax = max(abs(x)); % find the maximum value
x = x/xmax; % scaling the signal so the largest value(xmax) is 1
% time & discretisation parameters
N = length(x);
t = (0:N-1)/fs;
% spectral analysis
win = hanning(N); % sin window
% default is symmetric, periodic start at 0 at
% point 1, periodic Hann window is constructed by extending
% the desired window length by one sample, constructing a
% symmetric window, and removing the last sample
% symmetric starts at very close to zero ends at very close to zero
% hamming will being points slightly above 0, hanning starts at 0
K = sum(win)/N; % coherent amplification of the window
X = abs(fft(x.*win))/N; % Without abs it will give complex number
% abs will give the complex magnitude
% FFT of the windowed signal
NUP = ceil((N+1)/2); % calculate the number of unique points
% ceil = round off to nearest positive infinity
X = X(1:NUP); % FFT is symmetric, throw away second half
phase = unwrap(angle(fft(x.*win)));
phase = phase(1:NUP);
if rem(N, 2) % odd nfft excludes Nyquist point
% rem = reminder after division
X(2:end) = X(2:end)*2;
else % even nfft includes Nyquist point
% The DC component and Nyquist component,
% if it exists, are unique and should not be multiplied by 2
X(2:end-1) = X(2:end-1)*2;
end
f = (0:NUP-1)*fs/N; % frequency vector
%X = 20*log10(X); % spectrum magnitude
% plotting of the spectrum
figure()
plot(f, X, 'r') % Create a plot with a logarithmic scale for the x-axis and a linear scale for the y-axis
hold on
xlim([0 max(f)]) % set the limit for x axis
grid on
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
title('Amplitude Spectrum of the Signal')
xlabel('Frequency (Hertz)')
ylabel('Magnitude')
spectralcentroid = sum(X .* f')/sum(f);
plot(spectralcentroid,'*','MarkerSize',14)
hold off
%%Plotting amplitude against phase
figure()
plot(f,phase/180*pi)
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
title('Phase Spectrum of the Signal')
xlabel('Frequency (Hertz)')
ylabel('Phase (Radian)')
plotting of the spectrogram
figure()
len_seg=512; %window size 1024;
spectrogram(x, len_seg, 3/4*len_seg, [], fs, 'yaxis') % S = spectrogram(X,WINDOW,NOVERLAP,NFFT,Fs)
h = colorbar;
set(h, 'FontName', 'Times New Roman', 'FontSize', 14)
ylabel(h, 'Magnitude (Decibels)');
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('Time (Seconds)')
ylabel('Frequency (Hertz)')
title('Spectrogram of the Signal')
  3 件のコメント
crixus
crixus 2016 年 10 月 8 日
oops, I have edited my post and attach the data
dpb
dpb 2016 年 10 月 8 日
Doesn't make any difference; the problem is in the fundamental data collection and can't be cured except by sampling the input at (at least) 100 Hz, and probably preferably 2-3X times that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSonar and Spatial Audio についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by