필터 지우기
필터 지우기

what is happening actually in the following code?

조회 수: 1 (최근 30일)
Touhidul islam
Touhidul islam 2017년 12월 29일
답변: Star Strider 2017년 12월 29일
K = 8; % Cluster Numbers
CENTS = F( ceil(rand(K,1)*size(F,1)) ,:); % Cluster Centers
DAL = zeros(size(F,1),K+2); % Distances and Labels
KMI = 10; % K-means Iteration
for n = 1:KMI
for i = 1:size(F,1)
for j = 1:K
DAL(i,j) = norm(F(i,:) - CENTS(j,:));
end
*** I can't understand the below portions::::
[Distance, CN] = min(DAL(i,1:K)); % 1:K are Distance from Cluster Centers 1:K
DAL(i,K+1) = CN; % K+1 is Cluster Label
DAL(i,K+2) = Distance; % K+2 is Minimum Distance
end
  댓글 수: 1
Star Strider
Star Strider 2017년 12월 29일
If my Answer to your previous Question:
solved your problem, please Accept it!

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

채택된 답변

Star Strider
Star Strider 2017년 12월 29일
‘why CN is assigned to k+1 and distances to k+2 ?’
Apparently, whoever wrote the code designed the ‘DAL’ matrix to have specific data in specific columns.
Note that before the loop, ‘K’ is fixed at 8 and does not change within the code you posted, so ‘CN’ will be written in column 9 and ‘Distance’ in column 10 throughout the code.
Also, the min function with two outputs will return the first occurrence of the minimum value in the first output, and the index of that value in the second output. So ‘CN’ is the index, and ‘Distance’ is the value.

추가 답변 (1개)

Jan
Jan 2017년 12월 29일
The documentation explains the used commands exhaustively. Did you read it?
[Distance, CN] = min(DAL(i,1:K)); % 1:K are Distance from Cluster
See doc min : Distance is the smallest element of the vector DAL(i,1:K), while CN is the index of this element.
DAL(i,K+1) = CN; % K+1 is Cluster Label
DAL(i,K+2) = Distance; % K+2 is Minimum Distance
Now these two values are stored in the Matrix "DAL".
  댓글 수: 1
Touhidul islam
Touhidul islam 2017년 12월 29일
DAL(i,K+1) = CN;
DAL(i,K+2) = Distance;
why CN is assigned to k+1 and distances to k+2 ?

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

카테고리

Help CenterFile Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by