function Out=CombSet(A,B)
LA=length(A);
LB=length(B);
sub_A=reshape([ones(1,LA/2);zeros(1,LA/2)],1,LA);
sub_B=reshape([ones(1,LB/2);zeros(1,LB/2)],1,LB);
T_A=[A;sub_A];
T_B=[B;sub_B];
T_O=sortrows([T_A,T_B]',1);
Out=T_O(1,1);
Loop=1;
start=1;
num=1;
while (num<(LA+LB))
num=num+1;
if T_O(num,2)==1
start=start+1;
if start==1
Out=[Out,T_O(num,1)];
end
else
start=start-1;
if start==0
Out=[Out,T_O(num,1)];
end
end
end
function Out=CombSet(A,B)
LA=length(A);
LB=length(B);
sub_A=reshape([ones(1,LA/2);zeros(1,LA/2)],1,LA);
sub_B=reshape([ones(1,LB/2);zeros(1,LB/2)],1,LB);
T_A=[A;sub_A];
T_B=[B;sub_B];
T_O=sortrows([T_A,T_B]',1);
Out=T_O(1,1);
Loop=1;
start=1;
num=1;
while (num<(LA+LB))
num=num+1;
if T_O(num,2)==1
start=start+1;
if start==1
Out=[Out,T_O(num,1)];
end
else
start=start-1;
if start==0
Out=[Out,T_O(num,1)];
end
end
end
评论0
最新资源