フィルターのクリア

count values in a struct

4 ビュー (過去 30 日間)
elisa ewin
elisa ewin 2016 年 6 月 22 日
編集済み: Andrei Bobrov 2016 年 6 月 22 日
Hi! I have a sequence of trajectories organized in different clusters. The trajectories, in every cluster, are divided by daily scaled. In SetOfDataset(i).Interval2 (attached), i=1:60 number of possible cluster, every day is divided in interval of two hours so I have 12 interval and for every interval is indicated the location id of the user at that time. For example SetOfDataset(1).Interval2: this cluster has 5 days; for every day is indicated 12 intervals of 2 hours and in every interval is indicated la location of the user at that time.
I want to find how many times a single location is present in every interval.
E.g SetOfDataset(1).Interval2 5x1 cell, I want to find how many times the user stay in a location id in a determinate interval. For example I want to find location_id=260957 in SetOfDataset(1).Interval2, so i want like output a vector 1x12 in which I indicated the number of times location_id is 260957 in an interval.
Can you help me? If the question is not clear, because I have difficult to explain it, tell me and I try to explain better

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 6 月 22 日
編集済み: Andrei Bobrov 2016 年 6 月 22 日
t = cat(1,SetOfDataset(1).Interval2{:});
out = any(cellfun(@(x)any(x == 260957),t));
  2 件のコメント
elisa ewin
elisa ewin 2016 年 6 月 22 日
編集済み: elisa ewin 2016 年 6 月 22 日
it gives me an error:
Undefined operator '==' for input arguments of type 'cell'.
Error in @(z)any(z==260957)
Andrei Bobrov
Andrei Bobrov 2016 年 6 月 22 日
corrected

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by