Matlab: organize a great number of data based on month, day and hourly intervals

1 回表示 (過去 30 日間)
elisa ewin
elisa ewin 2016 年 6 月 16 日
コメント済み: elisa ewin 2016 年 6 月 16 日
Hi! I have a problem and I'm not able to find a smart solution. I explain it in short: I have a great number of user's sequence of location records and I have clustered them with cluster alghoritm optics. After find the cluster, I find the sequences of location records in every cluster. They are included in SetOfDataset (attached) end that is a struct 1x50, where 50 is the number of the cluster. Every sequence of locations has = [userId year month day hour minutes seconds latitude longitude locationID]
I want to divide this sequences based on month, day and, after identified the days, I want to divide them in intervals of 2 hours.
I have try to use nested struct but the code is terrible: slow, not clear the results... I want to do something of easy but I can't find smart ideas: can you help me?
  2 件のコメント
Guillaume
Guillaume 2016 年 6 月 16 日
編集済み: Guillaume 2016 年 6 月 16 日
"I want to divide this sequences based on month, day and, after identified the days, I want to divide them in intervals of 2 hours."
So what sort of output are you looking for for a given cluster?
elisa ewin
elisa ewin 2016 年 6 月 16 日
I want like output a struct (not nested) that have all the sequences with same day and month divided in interval of 2 hours

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

採用された回答

Guillaume
Guillaume 2016 年 6 月 16 日
It's not clear what final output you're looking for. Something like this:?
for setidx = 1 : numel(SetOfDataset)
points = SetOfDataset(setidx).points;
%divide date/hour in groups of two hours:
[~, ~, dateid] = unique([points(:, 2:4), floor(points(:, 5)/2)], 'rows', 'stable'); %'stable' optional
%use that to split the point array into cell arrays
SetOfDataset(setidx).splitpoints = arrayfun(@(did) points(did == dateid, :), [1:max(dateid)]', 'UniformOutput', false);
end
  3 件のコメント
Guillaume
Guillaume 2016 年 6 月 16 日
"I want also to divide the hours associated to every day in intervals of 2 hours"
It is doing this already. That's the purpose of the floor(points(:, 5)/2)
elisa ewin
elisa ewin 2016 年 6 月 16 日
sorry, I haven't noted this. Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by