# 将时间戳转换为matlab fft可用形式？

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.

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).

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