How to group variables in a same cluster ?
Show older comments
if I have
A=[1 2; 2 4; 3 4; 4 1; 5 1; 6 4; 7 4; 8 2; 9 1; 10 1]
where 1st column represents customer ID and 2nd column shows Clustering Number. How can I group customer ID into a same cluster such as
cluster1=[4 5 9 10], cluster2=[1,8], cluster3=[ ], cluster4=[2,3,6,7]
Accepted Answer
More Answers (1)
Guillaume
on 8 Jan 2018
Assuming your clustering numbers are all strictly positive integers:
accumarray(A(:, 2), A(:, 1), [], @(custs) {custs})
1 Comment
Pradya Panyainkaew
on 8 Jan 2018
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!