【发布时间】:2021-12-29 18:23:33
【问题描述】:
考虑以下数据:
A = [-1 -1 -1 0 1 -1 -1 0 0 1 1 1 1 -1 1 0 1];
如何计算A(相似邻居)中簇的大小和出现频率,最好使用MATLAB内置命令?
结果应该是这样的
s_plus = [1 2 3 4 5 ; 3 0 0 1 0]'; % accounts (1,1,1,1) and (1),(1),(1) which appear in A
s_zero = [1 2 3 4 5 ; 2 1 0 0 0]'; % accounts (0,0) and (0),(0) which appear in A
s_mins = [1 2 3 4 5 ; 1 1 1 0 0]'; % accounts (-1), (-1,-1) , and (-1,-1,-1)) which appear in A
上面第一列表示聚类大小,第二列表示出现频率。
【问题讨论】:
-
要找到具有大小的集群,您应该可以使用this solution;只需对所有
unique(A)元素进行循环即可找到各种值。
标签: arrays matlab cluster-analysis