📄 combinesingle.m
字号:
function comb =combinesingle(sa,n)
N = length(sa);
number = 0;
switch n
case 4
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
number = number + 1;
comb(:,number) = [tempcomb3,sa(i4)]';
end
end
end
end
case 5
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
number = number + 1;
comb(:,number) = [tempcomb4,sa(i5)]';
end
end
end
end
end
case 6
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
number = number + 1;
comb(:,number) = [tempcomb5,sa(i6)]';
end
end
end
end
end
end
case 7
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7 = i6+1:N
number = number + 1;
comb(:,number) = [tempcomb6,sa(i7)]';
end
end
end
end
end
end
end
case 8
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8 = i7+1:N
number = number + 1;
comb(:,number) = [tempcomb7,sa(i8)]';
end
end
end
end
end
end
end
end
case 9
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9 = i8+1:N
number = number + 1;
comb(:,number) = [tempcomb8,sa(i9)]';
end
end
end
end
end
end
end
end
end
case 10
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9= i8+1:N
tempcomb9= [tempcomb8,sa(i9)];
for i10 = i9+1:N
number = number + 1;
comb(:,number) = [tempcomb9,sa(i10)]';
end
end
end
end
end
end
end
end
end
end
case 11
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9= i8+1:N
tempcomb9= [tempcomb8,sa(i9)];
for i10= i9+1:N
tempcomb10= [tempcomb9,sa(i10)];
for i11 = i10+1:N
number = number + 1;
comb(:,number) = [tempcomb10,sa(i11)]';
end
end
end
end
end
end
end
end
end
end
end
case 12
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9= i8+1:N
tempcomb9= [tempcomb8,sa(i9)];
for i10= i9+1:N
tempcomb10= [tempcomb9,sa(i10)];
for i11= i10+1:N
tempcomb11= [tempcomb10,sa(i11)];
for i12 = i11+1:N
number = number + 1;
comb(:,number) = [tempcomb11,sa(i12)]';
end
end
end
end
end
end
end
end
end
end
end
end
case 13
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9= i8+1:N
tempcomb9= [tempcomb8,sa(i9)];
for i10= i9+1:N
tempcomb10= [tempcomb9,sa(i10)];
for i11= i10+1:N
tempcomb11= [tempcomb10,sa(i11)];
for i12= i11+1:N
tempcomb11= [tempcomb10,sa(i12)];
for i13 = i12+1:N
number = number + 1;
comb(:,number) = [tempcomb11,sa(i13)]';
end
end
end
end
end
end
end
end
end
end
end
end
end
case 14
for i1 = 1:N
tempcomb1 = sa(i1);
for i2 = i1+1:N
tempcomb2 = [tempcomb1,sa(i2)];
for i3 = i2+1:N
tempcomb3 = [tempcomb2,sa(i3)];
for i4 = i3+1:N
tempcomb4 = [tempcomb3,sa(i4)];
for i5 = i4+1:N
tempcomb5 = [tempcomb4,sa(i5)];
for i6 = i5+1:N
tempcomb6 = [tempcomb5,sa(i6)];
for i7= i6+1:N
tempcomb7= [tempcomb6,sa(i7)];
for i8= i7+1:N
tempcomb8= [tempcomb7,sa(i8)];
for i9= i8+1:N
tempcomb9= [tempcomb8,sa(i9)];
for i10= i9+1:N
tempcomb10= [tempcomb9,sa(i10)];
for i11= i10+1:N
tempcomb11= [tempcomb10,sa(i11)];
for i12= i11+1:N
tempcomb11= [tempcomb10,sa(i12)];
for i13= i12+1:N
tempcomb11= [tempcomb10,sa(i13)];
for i14 = i13+1:N
number = number + 1;
comb(:,number) = [tempcomb11,sa(i14)]';
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -