且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-27 09:24:37

我是不确定它是否实用,但是一种生成向量的方法,其中数据位置为1,其他位置为0如下所示:

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



这个 eventData vector可能是 HUGE


This eventData vector will likely be HUGE.


只需将其放入带有秒的向量中(将任何内容转换为秒,进行第一次)样本为零并从那里增加,换句话说,规范化你的值)并将数据分解成块,你可以在它上面做一个 fft()。该块的光谱分辨率等于fs / N,其中fs是采样频率,N是块大小(fft例程将根据传递给它的块大小选择fft大小,使用2 ^ N数字)。
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).


更多地考虑它,我不确定你真的需要使用FFT。

如果你只想要***的近似期信号,那么也许你应该使用线性回归。

使用类似的东西:

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



期限最合适,时间戳单位,事件之间的间隔

这12个点的期限约为325441.8


period is the best fit, in timestamp units, of the interval between "events"
With these 12 points the period is about 325441.8