%%随机生成16个9位二进制码按顺序赋给下列的单元格
A=randperm(512);
B=A(1:16);
M=[];
N=[];%用于存储联合的18位
for i=1:16
a=dec2bin(B(i),9);
M=[M;a]
end
%%测试是不是唯一码
for i=1:12
if mod(i,4)~=0
temp1=strcat(M(i,:),M(i+1,:))
temp2=strcat(M(i+1,:),M(i,:))
temp3=strcat(M(i,:),M(i+4,:))
temp4=strcat(M(i+4,:),M(i,:))
N=[N;temp1;temp2;temp3;temp4]
else
temp1=strcat(M(i,:),M(i+4,:));
temp2=strcat(M(i+4,:),M(i,:));
N=[N;temp1;temp2];
end
end
for i=13:15
temp1=strcat(M(i,:),M(i+1,:));
temp2=strcat(M(i+1,:),M(i,:));
N=[N;temp1;temp2];
end
N
num1=length(N)
num2=length(unique(N,'rows&#