FFT: Trouble with getting plausible frequencies

Hey,
I'm trying to solve following problem: I have data from digital drawings and want to calculate the frequencies of velocity and acceleration in order to define a tremor frequency. An example data set contains 289 measurements in 1.003 seconds. This is the code for the FFT I was trying to compute (X is the signal, for example velocity in cm/s, and timestamp defines when the data points were measured):
Fs = length(timestamp(timestamp <= 1)); %Frequency sample (data points in 1 second) = 288
T = 1/Fs; %Sample time = 0.0035
L = length(X); %Length of signal = 289
t = (0:L-1)*T; %Time vector
N = 2^nextpow2(L); %Next power of 2 = 512
Y = fft(X,N)/L; %FFT
f = Fs/2*linspace(0,1,N/2);
plot(f,2*abs(Y(1:N/2))) %Single-sided amplitude spectrum
With this code I get the attached plot that shows frequencies from 0 to 150Hz on the x-axis and peaks at approximately 60Hz and 100-120Hz.
According to the literature, the frequencies for velocity should be around 2-10Hz and not this high. I know that it is possible to use a Low-Pass filter on the data, but I cannot just cut off all frequencies higher than 20Hz, can I?
I'm now asking for help how I get more plausible frequencies and to understand if I'm calculating the FFT correctly for my kind of problem.
Thanks!
Julia

8 Comments

Are you sure your sample frequency is 288 Hz? This seems rather high if you are looking for frequencies around 10 Hz.
As well, if you're only recording 1 sec of data, there's barely 2 cycles even possible to have been collected for 2 Hz input; you need to be recording for much longer time spans to have any chance.
If you're seeing 60 and 120 Hz; you could have AC line noise contamination in the signal swamping what other actual signal there might be...check for ground loops, etc., ... Do you have isolated inputs?
Thanks for your answer but my data is already collected and I have no influence on the signal duration. This is a test set, the original data contains around 1000-2000 data points in 4-6 seconds.
My data looks like this: Timestamp in seconds, X-coordinate in cm, Y-coordinate in cm. From this I can see that there are 288 data points collected in 1 second what gives me a frequency sample of 288Hz, right?
Well, sometimes the data collection may not suffice to be able to do the analysis. The lowest frequency you can isolate well will be roughly whatever will have several cycles in the sample--so 1 sec recording 1 Hz is only one cycle which is not much for being able to resolve magnitude relative to a long-term process (presuming such a process is stationary, a key assumption).
Actually, if you had 288 sampled points in exactly 1 sec, the sampling frequency would be 287 Hz as there are N-1 sampling intervals, but in round numbers, yes.
Another problem may be that you say you have "timestamps" instead of sample time; if the data were collected on a polling basis instead of with strict sampling rate there's the uncertainty in timing between samples that introduces "jitter" and results in smearing energy amongst frequency bins. The assumption is also that sampling is uniform.
On the DC component; that's just a mean; removing it will simply remove the 0-frequency magnitude in the resulting PSD; it won't make any real difference otherwise.
IF, however, there's a linear or other baseline trend in the data, you may have some slight success if you remove it first.
@dpb: I'm not sure if I understand correctly what the AC noise contamination is, but is it really possible that I could get this for my kind of data? I'm recording coordinates and corresponding velocities from a digital drawing. How could I find out if there is an AC contamination?
I'm not having a strict sampling rate and I know that my results are therefore not correct. But I thought with pretending to have evenly spaced data I would at least yield results that do not differ that much from the correct ones.
As you probably notice, I'm not experienced in this kind of work, so I wanted to get closer to the correct results step by step and first get the FFT right.
dpb
dpb on 31 Jul 2018
Edited: dpb on 31 Jul 2018
I didn't know (and really still don't fully understand) what your actual process of collection is; I was presuming there was a A/D converter of some sort of signal in the chain somewhere along the way. If that isn't the case in whatever is doing the recording then it isn't the problem, no.
If the sampling rate is reasonably close it won't change the general shape and rough location of peaks; what is somewhat apparent is that there is a small indication of there being a roll-off from DC to about the 20 Hz area; that might be indicative of a trend.
The first thing I would do would be to do whatever it takes to get longer sample times if you're really interested in lower frequencies; and then look into averaging a number of measurements to see if any peaks come into prominence and other random noise goes away.
A more complete explanation of just what the data are and how they're acquired all the way from the beginning might help make more sense of interpreting the results.
It came out that there was a mistake in the collection of the data and now everything's working fine. Thanks again for your time and help!
That's more often the case than not, unfortunately.
"Question everything!"

Sign in to comment.

Answers (1)

Dimitris Kalogiros
Dimitris Kalogiros on 30 Jul 2018
Edited: Dimitris Kalogiros on 30 Jul 2018
Only 288 data points maybe are not enought to show you the spectrum of your data. With your code, you evaluate an FFT of length N=512. This means that matlab appent 512-288 zeros to your signal and the side effect of this fact is some noise at the spectrum. I suggest to use more than 1sec data interval.
More over, you can use more efficient functions to estimate spectrum of your data, for example pwelch().
And a last observation: your data look like they have a very strong dc component

5 Comments

Thank you! Like I've written above, I have no influence on the number of data points and the signal duration because I am analyzing a drawing. My "real" data sets contain around 1000-2000 data points but the spectrum doesn't look better.
To remove the DC component I have to remove the mean from my data, correct? Is it okay to do so or do you know how to prove that there is a strong DC component?
Indeed, you have to remove DC compontent from the data. But DC compontent is not your problem.
For the fft, the first data point in the output array is the zero frequency component, a.k.a. the DC component. Since the first point on the plot is almost 10 times the value it is anywhere else, you have a large DC component.
It makes sense to remove it by subtracting the mean off of your time domain data. The distracting first point is set to zero in the resulting fft plot, but the plot will be unchanged otherwise. As Dimitris mentioned, you still have the same issue as before.
The DC component in the PSD plot appears twice the size it actually is owing to the normalization of
plot(f,2*abs(Y(1:N/2)))
FFT returns only a single bin for the DC and Fmax components so doubling Y(1) doubles the actual DC magnitude.
It's still large in comparison to the rest of the spectrum but not quite so much as is shown.
Of course, as is said, removing it won't make any difference anywhere else; could just as effectively just set Y(1)=0;.
The underlying problem here appears to be in however these data were gathered not being up to the task desired or there simply not being the type of signal buried in the data as was expected.
Hello Julia,
Does the signal go on for quite a ways, or does it drop into the noise after a fairly short period of time? It would help if you could provide an example, 4-6 seconds of time and velocity data, say in a mat file.

Sign in to comment.

Products

Asked:

on 30 Jul 2018

Commented:

dpb
on 7 Aug 2018

Community Treasure Hunt

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

Start Hunting!