How can we run a loop to stack data for each day in both years (use 12 hours in each day)?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix with 4 columns in a mat file
we have two-year data and each day has 12 sections.
How can we run a loop to stack data for each day in both years (use 12 hours in each day)?
for e.g
% this is how data looks like
year day NCF Hour
2018 282 3001x1 double 1
2018 282 3001x1 double 2
2018 282 3001x1 double 3
2018 282 3001x1 double 4
2018 282 3001x1 double 5
2018 282 3001x1 double 6
2018 282 3001x1 double 7
2018 282 3001x1 double 8
2018 282 3001x1 double 9
2018 282 3001x1 double 10
2018 282 3001x1 double 11
2018 282 3001x1 double 12
2018 283 3001x1 double 1
2018 283 3001x1 double 2
2018 283 3001x1 double 3
2018 283 3001x1 double 4
2018 283 3001x1 double 5
2018 283 3001x1 double 6
2018 283 3001x1 double 7
2018 283 3001x1 double 8
2018 283 3001x1 double 9
2018 283 3001x1 double 10
2018 283 3001x1 double 11
2018 283 3001x1 double 12
... ... ....... ...
... ... ....... ...
2019 365 ............... 12
0 件のコメント
回答 (1 件)
Mohammad Sami
2021 年 3 月 17 日
編集済み: Mohammad Sami
2021 年 3 月 17 日
I am assuming this is a struct. Also assuming that data in NCF is the same size.
%convert to table.
% mydata = struct();
t = struct2table(mydata);
% make sure that the data is sorted by year, day, hour
t = sortrows(t,{'year','day','hour'},'ascend');
ncf = horzcat(t.NCF{:})';
% assuming you want the year, day, hour in the same way
n = 3001
y = repelem(t.year,n);
d = repelem(t.day,n);
h = repelem(t.hour,n);
3 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!