필터 지우기
필터 지우기

sorting the outputs of clusters

조회 수: 4 (최근 30일)
Haya A
Haya A 2018년 4월 18일
댓글: Walter Roberson 2018년 4월 19일
I applied K-means clustering, and I tried to sort the outputs of each cluster individually. for example, if I got 2 clusters, I want to sort the contents of each cluster, and save the result or the output in a table to reuse it again in another function.
how can I do that?
  댓글 수: 1
Stephen23
Stephen23 2018년 4월 18일
편집: Stephen23 2018년 4월 18일
Note that rather than saving data into separate variables it is usually easier and more versatile to split data into something like a cell array: then it will scale easily to a different number of clusters, and makes looping over them trivial. Read more about why here:

댓글을 달려면 로그인하십시오.

답변 (1개)

njj1
njj1 2018년 4월 18일

What do you mean "sort". You could save them to different variables. For example, if you main matrix is called X and you have cluster information stored in a vector called idx, and there are two clusters numbered 1 and 2:

X1 = X(idx==1,:);
X2 = X(idx==2,:);

Is this what you mean?

  댓글 수: 6
Haya A
Haya A 2018년 4월 19일
actually, what I meant is : after clustering, I wanted adds all vectors into one vector in each cluster and then sort that vector.
Walter Roberson
Walter Roberson 2018년 4월 19일
Add all what vectors into one vector? And is this one vector per cluster or one vector total?
Are you asking to go through each cluster and sort() its centroid location??
Are you asking to go through the original points, separate them according to cluster number, concatenate all of the rows (that are the input values for clustering to work on) for the cluster into one vector and then sort that vector, even though that would mean sorting x, y, z, ... coordinates all together?
Are you assuming that your inputs are scalars for each sample (only one coordinate) and so the sorting of the different columns of coordinates together does not matter because there would only be one column?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by