フィルターのクリア

Reshape hourly mean values with missing data/ non-uniform data

6 ビュー (過去 30 日間)
Venkata
Venkata 2017 年 5 月 11 日
コメント済み: Venkata 2017 年 5 月 12 日
Hi, I could get the hourly averages from minute interval data, using unique and accumarray functions.
I would like to arrange the averaged values in a matrix but there might be some data (hours) missing.
For e.g. my output matrix should look like:
yy mm dd hr1 hr2 hr3 ... 0 0 0 hr20 ... 0
yy mm dd 0 0 0 ... hr10 ..... 0 0 hr24
Is there a way to identify the missing hours data and put zeros there and to create this matrix...!
Thank you.
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 5 月 11 日
Do you have a new enough version of MATLAB that you could switch to timetable() objects instead? R2016b or newer I think it is.
Venkata
Venkata 2017 年 5 月 11 日
No, I am using R2016a. Is there any work around?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 11 日
Supposing that T is a vector of datenum for each reading (the timestamp) and D is the corresponding value, then
dv = datevec(T);
days = datenum([dv(:,1), dv(:,2), dv(:,3)]);
[unique_days, uidxa, uidxc] = unique(days);
hours = dv(:,4);
summary_data = accumarray( [uidxc, hours+1], D(:), [], @mean);
summary_table = [dv(uidxa,1:3), summary_data];
  1 件のコメント
Venkata
Venkata 2017 年 5 月 12 日
Thanks a ton, Walter Roberson.
It worked like a charm.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by