冷凝库存数据

发布于 2024-08-11 12:54:50 字数 1137 浏览 3 评论 0原文

我有一个这样组成的数据集:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

默嘫て 2024-08-18 12:54:50

首先,使用 datenum 将年、月、日、时、分、秒变量转换为 times:

datenum(2009,11,01,17,00,23)

将返回自 1/1/0000 以来过去的天数。
假设您将所有时间保存在一个名为 times 的向量中。
现在,应该很容易找到您的第一次/最后一次时间:

first = min(times); 
last = max(times);

一分钟等于:

ONE_MINUTE = 1/24/60

现在分箱完成如下:

index = 1;
means = [];
for t = first:5*ONE_MINUTE:last
    current_bin = (times>=t) & (times<t+5*ONE_MINUTE)
    % do something with all the data for which current_bin==1
    means(index) = mean(data(current_bin));
    index = index+1;
end

仅举个例子,我计算了每个箱中数据的平均值。我假设你有一个名为 data 的向量,其中每次都包含一些数据。

(我知道这可以优化很多,但对于这个答案,我更喜欢清晰度而不是性能)

First, use datenum to convert your year,month,day,hour,minute,second variables to times:

datenum(2009,11,01,17,00,23)

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:

first = min(times); 
last = max(times);

one minute is equal to:

ONE_MINUTE = 1/24/60

now the binning is done like:

index = 1;
means = [];
for t = first:5*ONE_MINUTE:last
    current_bin = (times>=t) & (times<t+5*ONE_MINUTE)
    % do something with all the data for which current_bin==1
    means(index) = mean(data(current_bin));
    index = index+1;
end

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文