資源簡介
matlab 中連續區間進行交并集操作,輸入輸出為向量表示的連續區間如A=[a,b,c,d]表示A=(a,b)U(c,d),A為最簡表達式,各個集合不相交

代碼片段和文件信息
function?Out=CombSet(AB)
LA=length(A);
LB=length(B);
sub_A=reshape([ones(1LA/2);zeros(1LA/2)]1LA);
sub_B=reshape([ones(1LB/2);zeros(1LB/2)]1LB);
T_A=[A;sub_A];
T_B=[B;sub_B];
T_O=sortrows([T_AT_B]‘1);
Out=T_O(11);
Loop=1;
start=1;
num=1;
while?(num<(LA+LB))
????num=num+1;
????if?T_O(num2)==1
????????start=start+1;
?????????if?start==1
????????Out=[OutT_O(num1)];
????????end
????else
????????start=start-1;
????????if?start==0
????????Out=[OutT_O(num1)];
????????end
????end
????????
end
function?Out=CombSet(AB)
LA=length(A);
LB=length(B);
sub_A=reshape([ones(1LA/2);zeros(1LA/2)]1LA);
sub_B=reshape([ones(1LB/2);zeros(1LB/2)]1LB);
T_A=[A;sub_A];
T_B=[B;sub_B];
T_O=sortrows([T_AT_B]‘1);
Out=T_O(11);
Loop=1;
start=1;
num=1;
while?(num<(LA+LB))
????num=num+1;
????if?T_O(num2)==1
????????start=start+1;
?????????if?start==1
????????Out=[OutT_O(num1)];
????????end
????else
????????start=start-1;
????????if?start==0
????????Out=[OutT_O(num1)];
????????end
????end
????????
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1074??2019-10-13?19:06??CombSet.m
?????文件????????560??2019-10-13?19:08??IntSet.m
-----------?---------??----------?-----??----
?????????????????1634????????????????????2
- 上一篇:粒子群算法無功優化程序
- 下一篇:指紋預處理圖matlab實現
評論
共有 條評論