Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all! i have the following timestamps of detection time below and tens of thousands more not not posted.
I am dying to know how to transform these numbers into a matlab FFT function usable form so that i can find the period of the signal. Pls help out this beginner here!


VB
82473035994223.000000
82473036321275.000000
82473036758714.000000
82473037152621.000000
82473037463611.000000
82473037735504.000000
82473038019083.000000
82473038281295.000000
82473038636703.000000
82473039013925.000000
82473039348376.000000
82473039596255.000000


What i have thought of is this, by giving the timestamps a value of 1, and trying to fill out the in betweens times with values of 0. But i do not know how to implement the action of filling out the in betweens with 0 and how to put it into the fft. pls advise!

VB
82473035994223.000000    1
82473036321275.000000    1
82473036758714.000000    1
82473037152621.000000    1
82473037463611.000000    1
82473037735504.000000    1
Posted

I'm not sure it is practical, but a way to generate a vector where there's a 1 at the data positions and 0 everywhere else would be something like:
rawTimes = [82473035994223.000000
82473036321275.000000
82473036758714.000000
82473037152621.000000
82473037463611.000000
82473037735504.000000
82473038019083.000000
82473038281295.000000
82473038636703.000000
82473039013925.000000
82473039348376.000000
82473039596255.000000
# etc.];
reducedTimes = fix(rawTimes .- rawTimes(1));  # shift the absolute times to be INTEGER offsets
eventData = zeros(1, 1+reducedTimes(end));
eventData(1+reducedTimes) = 1;
# now you can fft(eventData);

This eventData vector will likely be HUGE.
 
Share this answer
 
Comments
Member 10512547 10-Feb-14 15:20pm    
you were right,i tried this and i got out of memory.
Matt T Heffron 10-Feb-14 15:40pm    
Can you reduce the SPAN of the data (i.e., size of eventData) by reducing the precision of the data?
E.g., if the time stamps are in seconds but you only need the calculation to hours, then divide rawTimes by 3600 before calculating reducedTimes (and probably changing fix() to round() ). That reduces the size of the eventData vector by a factor of 3600.
Albert Holguin 10-Feb-14 20:25pm    
I gave him some suggestions... basically has to normalize the data then run in blocks...
Matt T Heffron 10-Feb-14 15:45pm    
You probably ought to see if you can use Matlab sparse matrices, and if they're compatible with fft().
Something like:
eventData = sparse(1+reducedTimes, 1, 1);
This could work with fft(). Assuming it doesn't forcibly expand the vector internally...
Just put it in a vector with seconds (transform whatever that is to seconds, make the first sample be zero and increase from there, in another words, normalize your values) and break up the data into blocks and you can do an fft() on it. The block will have a spectral resolution equal to fs/N, where fs is the sampling frequency and N is the block size (the fft routine will pick the fft size based on the block size that you pass to it, using a 2^N number).
 
Share this answer
 
Comments
Member 10512547 10-Feb-14 22:18pm    
i have normalised it as u said, but what do you mean by breaking up into blocks? do i just fft(normaliseddata)?
Albert Holguin 10-Feb-14 22:30pm    
How many data samples do you have? ...if it's a huge number, then you can do a faster FFT by breaking it up into smaller chunks, and you'll still get the information you need. For example, you can break it up into chunks of 8K data points and feed that into the FFT. The FFT will essentially give you a spectral window into that chunk of time, you can move your window over as needed.
Member 10512547 10-Feb-14 22:32pm    
i have about more than one million points.
Albert Holguin 10-Feb-14 22:36pm    
yeah, well break that up into some number, preferably some amount that is a power of two (2^N), since that's what the fft routine will use (if you don't feed it exactly that, it zero pads).
Member 10512547 10-Feb-14 22:43pm    
is this correct then?

using 8192 points

X = rawTimes - rawTimes(1);/* normalising*/
X = X*(10e^-12)*81; /* since 1 time stamp unit is 81ps */

plot(fft(X,8192));
Thinking about it more, I'm not sure you really need to use an FFT.
If you just want the best approximation to the period of the signal, then maybe you should use Linear Regression.
Use something like:
rawTimes = [82473035994223.000000
82473036321275.000000
82473036758714.000000
82473037152621.000000
82473037463611.000000
82473037735504.000000
82473038019083.000000
82473038281295.000000
82473038636703.000000
82473039013925.000000
82473039348376.000000
82473039596255.000000
# etc.];
X = rawTimes .- rawTimes(1);  # unlike Solution 1, these no longer need to be integer
Y = 1:(size(X)(1));
fit = polyfit(X, Y', 1);
period = 1./fit(1);

period is the best fit, in timestamp units, of the interval between "events"
With these 12 points the period is about 325441.8
 
Share this answer
 
v3
Comments
Member 10512547 10-Feb-14 22:21pm    
i got an error
>> Y = 1:(size(X)(1));
Error: ()-indexing must appear last in an index expression.

what does it mean?
Matt T Heffron 11-Feb-14 12:03pm    
I don't know what the problem is here, I used this EXACT statement when I tried this.
Matt T Heffron 11-Feb-14 12:30pm    
Perhaps:
[XL, ignore] = size(X);
Y = 1:XL;
Member 10512547 10-Feb-14 22:26pm    
Also,i forgot to mention that within the detection timestamps i obtained, some might be darkcounts, meaning a false detection so this method might not really work.
Matt T Heffron 11-Feb-14 12:01pm    
If you know which are which, use only the ones that are positive events.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900