echo off;
%确定矩阵参数
dim=size(H);
rows=dim(1);
cols=dim(2);
cycle8num = 0;
cycle8(:,4) = 0;
for irow1 = 1:rows
for jcol1 = 1:cols
if H(irow1,jcol1) ==1;
onesInRow1 = find(H(irow1,:));
for ilevel1=1:length(onesInRow1)
jcol2 = onesInRow1(ilevel1);
if jcol2 > jcol1
onesInCol2 = find(H(:,jcol2));
for jvertical1 = 1:length(onesInCol2)
irow2 = onesInCol2(jvertical1);
if irow1~=irow2
onesInRow2 = find(H(irow2,:));
for ilevel2 = 1:length(onesInRow2)
jcol3 = onesInRow2(ilevel2);
if jcol3 > jcol2
onesInCol3 = find(H(:,jcol3));
for jvertical2 = 1:length(onesInCol3)
irow3 = onesInCol3(jvertical2);
if irow2~=irow3
onesInRow3 = find(H(irow3,:));
for ilevel3 = 1:length(onesInRow3)
jcol4 = onesInRow3(ilevel3);
if jcol4 > jcol3
onesInCol4 = find(H(:,jcol4));
for jvertical3 = 1:length(onesInCol4)
irow4 = onesInCol4(jvertical3);
if irow3~=irow4
onesInRow4 = find(H(irow4,:));
for ilevel4 = 1:length(onesInRow4)
jcol5 = onesInRow4(ilevel4);
if jcol5 ==jcol1&&jcol5~=jcol4
cycle8num = cycle8num + 1;
cycle8(cycle8num,:) = [jcol1,jcol2,jcol3,jcol4];
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
%cycle8 = replace(cycle8)
% H=[1 0 0 0 1;1 0 1 0 1;0 0 1 0 1]