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

1 次查看(过去 30 天)
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)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by