冷凝库存数据
我有一个这样组成的数据集:
2009,11,01,17,00,23,1.471700,1.472000
2009,11,01,17,01,04,1.471600,1.471900
2009,11,01,17,01,09,1.471900,1.472100
2009,11,01,17,01,12,1.472000,1.472300
2009,11,01,17,01,13,1.471900,1.472200
2009,11,01,17,01,14,1.471600,1.471900
2009,11,01,17,01,18,1.471700,1.472000
2009,11,01,17,01,18,1.471900,1.472200
我正在使用 Octave 来操作该数据。我想使用此刻度数据创建包含 5 分钟、10 分钟和 30 分钟间隔数据的各种文件。使用这种格式,可以将它们绘制为条形图/烛台图并执行进一步的计算。但是,我真的不知道如何通过数据循环来创建此类文件。
我熟悉 Octave 并使用该软件,但可以在其他一些软件中执行此特定任务以生成文件以便稍后导入到 Octave 中。
我第一次尝试在 Octave 中对此进行编码会出现以下错误:-
error: A(I,J,...) = X: dimensions mismatch
error: called from:
error: /home/andrew/Documents/forex_convert/tick_to_min.m at line 105, column 25
生成它的代码是
[i,j]=find(fMM>=45 & fMM<50);
min_5_vec(1:length(i),1)=tick_data(min(i):max(i),1); % line 105
该代码检查“分钟”向量 fMM 并应提取并创建一个新的“min_5_vec”向量,其中包含 HH 时间之间发生的所有刻度数据:每小时 45:00 和 HH:49:59。问题是这段代码是函数的一部分,似乎仅在这一特定行上失败,我觉得这很奇怪,因为它已被复制和粘贴,并且仅更改了数字 45 和 50,以及其他类似部分第 105 行之前的功能代码不会失败。我目视检查了原始数据,看不出数据的性质是失败的原因。对于失败的可能原因有什么建议吗?
I have a data set that is composed as such:
2009,11,01,17,00,23,1.471700,1.472000
2009,11,01,17,01,04,1.471600,1.471900
2009,11,01,17,01,09,1.471900,1.472100
2009,11,01,17,01,12,1.472000,1.472300
2009,11,01,17,01,13,1.471900,1.472200
2009,11,01,17,01,14,1.471600,1.471900
2009,11,01,17,01,18,1.471700,1.472000
2009,11,01,17,01,18,1.471900,1.472200
I am using Octave to manipulate this data. I would like to use this tick data to create various files containing the data in 5, 10. and 30 minute intervals. With this format they could be plotted as a bar/candlestick chart and further calculations performed. However, I don't really have any idea how to approach the looping over the data to create such files.
I am familiar with Octave and use this software, but this particular task could be undertaken in some other software to produce files for later import into Octave.
My first attempt to code this in Octave gives this error:-
error: A(I,J,...) = X: dimensions mismatch
error: called from:
error: /home/andrew/Documents/forex_convert/tick_to_min.m at line 105, column 25
The code that produces it is
[i,j]=find(fMM>=45 & fMM<50);
min_5_vec(1:length(i),1)=tick_data(min(i):max(i),1); % line 105
The code checks the "minutes" vector fMM and should extract and create a new "min_5_vec" vector containing all tick data that occurred between the times HH:45:00 and HH:49:59 for every hour. The thing is this code, which is part of a function, appears to fail only on this particular line which I find very strange as it has been copied and pasted and only the figures 45 and 50 have been changed, and the other similar parts of the function code up to line 105 do not fail. I have visually checked the raw data and can see no cause for the nature of the data to be the reason for the failure. Any suggestions for the possible cause of the failure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,使用 datenum 将年、月、日、时、分、秒变量转换为 times:
将返回自 1/1/0000 以来过去的天数。
假设您将所有时间保存在一个名为 times 的向量中。
现在,应该很容易找到您的第一次/最后一次时间:
一分钟等于:
现在分箱完成如下:
仅举个例子,我计算了每个箱中数据的平均值。我假设你有一个名为 data 的向量,其中每次都包含一些数据。
(我知道这可以优化很多,但对于这个答案,我更喜欢清晰度而不是性能)
First, use datenum to convert your year,month,day,hour,minute,second variables to times:
will return the number of days past since 1/1/0000.
lets say you save all the times in a vector called times.
now, it should be easy enough to find the first/last time you have:
one minute is equal to:
now the binning is done like:
Just for the example, I calculated the means of the data in each bin. I assume you have a vector called data which contains some data for each time.
(I know this can be optimized a lot, but I preferred clarity over performance for this answer)