How Do I Use Fft Function In Matlab To Find The Frequency For A Set Of Data Points?

hi ive been given a set of about 20k data points. i managed to import the data into matlab and did the following,
importdata; fft(importdata);
and it says Undefined function 'fft' for input arguments of type 'cell'. now i understand i need more than this to get it working, can someone please tell me any more parameters i need for the fft and how to implement it?
edit: these datapoints are timestamps of when something is detected in a machine, im trying to find if there is a period of the detection occuring.
anyone have ideas how to trasnform it so i can use matlab fft? Imp

 Accepted Answer

If what you have is the times of occurrences, then a fft is inappropriate. - FFTs require regularly sampled data.
I don't know what your "importdata" looks like. You'll need to provide a description.
If what your data looks like is something like a table of
timestamp: event
timestamp: event
Then you can simply calculate the difference between each time stamp. If you then plot the difference in timestamp, you'll probably see several clusters of values. Each cluster is likely to be the period of a regular event - or a multiple of it.

4 Comments

my data looks like these 82473037165339.000000 82473037844594.000000 82473038806939.000000 82473039098883.000000 82473039296216.000000 82473039876576.000000 82473040071373.000000
there might be machine errors in the occurences too. i tried to do what u said in c++ but it was kinda hard and takes rather long due to my poor programming skills. but anyway, does this means i totally cant use fft?
You CAN use FFT, but its harder than doing what I said.
I guess that what you have in "importdata" is a cell array that contains a vector of those values. If I'm right with that guess, then this code should be what you need:
plot(diff(importdata{1}),'x')
What that will give you is a plot, with each time between events plotted as a single x on a chart. I would expect to see a few straight-ish, horizontal lines with fairly regular spacing, and a few points sticking out in the middle of nowhere. If your event happens every second, you'll see one "straight" line with a few outliers where something went slightly skew-whiff. If its multiple straight lines, then its likely to be more complicated, but it could just be that the thing detecting the events misses a few events (like every 7th or something stupid like that)
hi Iain,
i entered that code but nothing happened,pardon me for asking, what does the function diff(importdata{1}) do and what does 'x' refer to?
Thanks alot
importdata{1}, is where I've assumed that a vector of those time stamps is. - I can't see your data so I don't know if it's right.
diff( vector ) simply subtracts the 2nd element from the 1st, the 3rd from the 2nd, etc. and returns a vector of those differences.
plot( vector, 'x') plots each value in the vector, with crosses instead of as a line.

Sign in to comment.

More Answers (0)

Categories

Asked:

Fam
on 24 Jan 2014

Commented:

on 29 Jan 2014

Community Treasure Hunt

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

Start Hunting!