%% Example Title
% Summary of example objective
%% Section 1 Title
% Description of first code block
%将Excel表中数据读取至MATLAB中
%[NUM]=xlsread('Define');
[NUM]=xlsread('testData');
%读取初始要素的个数
length=size(NUM,1);
%获得影像因素的最大个数
maxlen=size(NUM,2);
%将要素-影像因素表转换为邻接矩阵
adjacentMatrix=zeros(length,length);
for i=1:length
j=1;
while(j<=maxlen&&isnan(NUM(i,j))==0)
adjacentMatrix(i,NUM(i,j))=1;
j=j+1;
end;
end;
adjacentMatrix=adjacentMatrix-eye(length,length);
save adjacentMatrix;
%生成单位矩阵
I=eye(length);
%生成可达矩阵
rMatrix=(adjacentMatrix|I);
reachableMatrix=(adjacentMatrix|I);
for i=1:length
reachableMatrix=logicMultiply(reachableMatrix,rMatrix);
end;
save reachableMatrix;
%输出关联回路
r=1;
for i=1:(length-1)
for j=(i+1):length
if(isequal(reachableMatrix(i,:),reachableMatrix(j,:)))
contactLoop(r,:)=[i,j];
r=r+1;
end;
end;
end;
save contactLoop;
%约简回路
CreachableMatrix=reachableMatrix;
l=1;
for(i=1:size(contactLoop,1))
if(i<2||(i>=2&&contactLoop(i,1)~=contactLoop(i-1,1)))
CreachableMatrix((contactLoop(i,1)-l+1),:)=[];
Edelete(l,1)=contactLoop(i,1);
l=l+1;
end;
end;
save Edelete;
l=1;
for(j=1:size(contactLoop,1))
if(j<2||(j>=2&&contactLoop(j,1)~=contactLoop(j-1,1)))
CreachableMatrix(:,(contactLoop(j,1)-l+1))=[];
l=l+1;
end;
end;
save CreachableMatrix;
%生成骨架矩阵
II=eye(size(CreachableMatrix,1));
skeletonMatrix=CreachableMatrix-II-logicMultiply((CreachableMatrix-II),(CreachableMatrix-II));
save skeletonMatrix;
%% Section 2 Title
% Description of second code block
a=2;