📄 step11.asv
字号:
% step11.m (combination)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% construct a distance matrix
% it's a triangle matrix to avoid repeated distance
% each element notes the distance between two centers
% step11.m include ISODATA Step 11,12,13
ctr_dist=zeros(c,c); % center distance matrix
for m=1:c
for n=1:c
if m<n
ctr_dist(m,n)=ecld_dist(Z(m,:),Z(n,:));
else
ctr_dist(m,n)=inf;
end
end
end
% ------------------------------------
% choose the classes that need to be combined
% Min_Dist_Ctr is the output of this part
% it contains the position of the smallest L centers
Min_Dist_Ctr=zeros(L,2);
for k=1:L
[temp mincetrpos]=min(ctr_dist(:));%minimum center distance
if temp<theta_c
clear temp
[Min_Dist_Ctr(k,1) Min_Dist_Ctr(k,2)]=ind2sub(size(ctr_dist),mincetrpos);
ctr_dist(mincetrpos)=inf;
end
end
%合过的不合
if sum(Min_Dist_Ctr(:))~=0
for q=1:length(Min_Dist_Ctr(:))
for p=q+1:length(Min_Dist_Ctr(:))
if Min_Dist_Ctr(p)==Min_Dist_Ctr(q)
[tempx tempy]=ind2sub(size(Min_Dist_Ctr), p);
Min_Dist_Ctr(tempx,:)=[0 0];
end
end
end
end
% ------------------------------------
% combination according to Min_Dist_Ctr
if sum(Min_Dist_Ctr(:))~=0
for k=1:size(Min_Dist_Ctr,1)
if Min_Dist_Ctr(k,1)~=0
sumtwoclass=s{5,Min_Dist_Ctr(k,1)}+s{5,Min_Dist_Ctr(k,2)};
% add a new class center
Z(end+1,:)= (s{5,Min_Dist_Ctr(k,1)}*s{1,Min_Dist_Ctr(k,1)}+s{5,Min_Dist_Ctr(k,2)}*s{1,Min_Dist_Ctr(k,2)})/sumtwoclass;
% delete original two class centers
Z([Min_Dist_Ctr(k,1) Min_Dist_Ctr(k,2)],:)=[];
c=c-1;
end
end
end
J=J+1;
%%%Author: Feng Shuo%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -