Form a matrix with variable number of columns (with fixed row numbers)
3 次查看(过去 30 天)
显示 更早的评论
I'm clustering a 70,000x3 data matrix(say X is data and K is no. of clusters). For that I want to store the index value (positions) of data points belonging to each cluster(required for further calculations and work) . As per the problem, it would be like Y[c, j] (c = cluster number, j = index vslue of data point ). But, the clusters formed isn't equally distributed. The number of data points belonging to different clusters will be different. Is there a way to form such matrix with variable number of columns and fixed number of rows? If not, please suggest the another way.
Thanks in advance !
0 个评论
采纳的回答
Walter Roberson
2018-12-19
Just store the cluster number for each point. If you need to know which points belong to one particular cluster then use logical masks idx == cluster_number or find(idx == cluster_number). If you do that a lot, then calculate it once and store in cell arrays.
If it is for some reason particularly important to store everything in a single numeric array, then zero pad or nan pad the shorter rows.
0 个评论
更多回答(1 个)
Image Analyst
2018-12-19
Why should they have the same number? What if there aren't? I guess you could force one by taking the principal components with pca() and then sorting on PC1 and the splitting it at the half way point into two clusters. Would that do what you want?
Also, what is X and K? Is K the number of clusters you want, like 2 or 3? Then what is X?
Attach your data with the paper clip icon, and a screenshot of it plotted with scatter3() using the insert frame icon.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!