我已经使用下面的脚本读取我的数据(下面的示例),并且能够通过使用日期和时间标记来计算热通量(H)的每小时和每日平均值。困难在于我也想要15分钟,30分钟等平均值。如何用我拥有的数据做到这一点?
LASfile=fopen('../../data/heat.txt');
Data = textscan(LASfile, '%16c %*24c %s %s %f %f %f %d %d %d %d','headerlines',1);
fclose(LASfile);
H = Data {6};
%%
date_num = datestr(Data{1});
formatIn = 'dd-mmm-yyyy HH:MM:SS';
DateVector = datevec(date_num, formatIn);
%%
% Group by day and hour
[unDates, ~, subs] = unique(DateVector(:,1:4),'rows');
% Accumulate by day
[unDates accumarray(subs, H, [], @mean)]; %computes hourly heat flux
#timeStamp date time Cn2 CT2 H
2012-02-07 11:56:00 2/7/2012 11:56:00 3.11E-13 3.64E-01 330.5
2012-02-07 11:57:00 2/7/2012 11:57:00 2.22E-13 2.60E-01 256.4
2012-02-07 11:58:00 2/7/2012 11:58:00 2.92E-13 3.42E-01 315.3
2012-02-07 11:59:00 2/7/2012 11:59:00 4.07E-13 4.77E-01 404.4
2012-02-07 12:00:00 2/7/2012 12:00:00 3.56E-13 4.17E-01 365.7
2012-02-07 12:01:00 2/7/2012 12:01:00 4.41E-13 5.17E-01 429.3
2012-02-07 12:02:00 2/7/2012 12:02:00 4.23E-13 4.96E-01 416.3
2012-02-07 12:03:00 2/7/2012 12:03:00 3.17E-13 3.72E-01 335.3
2012-02-07 12:04:00 2/7/2012 12:04:00 3.42E-13 4.00E-01 354.7
2012-02-07 12:05:00 2/7/2012 12:05:00 3.43E-13 4.02E-01 355.6
2012-02-07 12:07:00 2/7/2012 12:07:00 2.92E-13 3.42E-01 315.3
2012-02-07 12:08:00 2/7/2012 12:08:00 2.63E-13 3.09E-01 291.7
2012-02-07 12:09:00 2/7/2012 12:09:00 2.45E-13 2.87E-01 276.1
2012-02-07 12:10:00 2/7/2012 12:10:00 3.00E-13 3.52E-01 321.8
2012-02-07 12:11:00 2/7/2012 12:11:00 3.77E-13 4.42E-01 382
2012-02-07 12:12:00 2/7/2012 12:12:00 4.40E-13 5.16E-01 428.9
2012-02-07 12:13:00 2/7/2012 12:13:00 3.60E-13 4.22E-01 369.2
2012-02-07 12:14:00 2/7/2012 12:14:00 4.56E-13 5.35E-01 440.4
2012-02-07 12:15:00 2/7/2012 12:15:00 3.62E-13 4.24E-01 370.5
2012-02-07 12:16:00 2/7/2012 12:16:00 3.48E-13 4.07E-01 359.3
2012-02-07 12:17:00 2/7/2012 12:17:00 3.94E-13 4.62E-01 394.9
2012-02-07 12:18:00 2/7/2012 12:18:00 3.53E-13 4.14E-01 363.5
2012-02-07 12:19:00 2/7/2012 12:19:00 4.47E-13 5.24E-01 433.6
2012-02-07 12:20:00 2/7/2012 12:20:00 4.33E-13 5.07E-01 423.6
2012-02-07 12:21:00 2/7/2012 12:21:00 3.18E-13 3.73E-01 336
2012-02-07 12:22:00 2/7/2012 12:22:00 2.91E-13 3.41E-01 314.7
2012-02-07 12:23:00 2/7/2012 12:23:00 2.71E-13 3.17E-01 297.8
2012-02-07 12:24:00 2/7/2012 12:24:00 3.72E-13 4.36E-01 378.2
2012-02-07 12:25:00 2/7/2012 12:25:00 3.25E-13 3.81E-01 341.8
2012-02-07 12:26:00 2/7/2012 12:26:00 3.66E-13 4.29E-01 373.3
2012-02-07 12:27:00 2/7/2012 12:27:00 3.95E-13 4.63E-01 395.3
2012-02-07 12:28:00 2/7/2012 12:28:00 3.73E-13 4.37E-01 378.9
2012-02-07 12:29:00 2/7/2012 12:29:00 3.31E-13 3.89E-01 346.7
2012-02-07 12:30:00 2/7/2012 12:30:00 3.05E-13 3.57E-01 325.7
答案 0 :(得分:0)
您应该将DateVector
的第五个元素包含在您需要的四舍五入中。例如,使用15分钟的时间段:
DateVector2 = DateVector(:,1:5);
DateVector2(:,5) = floor(DateVector(:,5)/15);
然后根据此accumarray
DateVector2
[unDates, ~, subs] = unique(DateVector2,'rows');
% Accumulate by day
[unDates accumarray(subs, H, [], @mean)]; %computes average heat flux