1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
SegmentsCommuns = [16 10; 6 14; 12 2; 1 11; 14 5; 11 12; 9 16]
% **** Mise en vecteur colonne des Segments communs
SegmentsCommuns2 = [SegmentsCommuns(:,1);SegmentsCommuns(:,2)];
% **** Récupération des indices
[iictttii,iiuii,iivii]=unique(SegmentsCommuns2,'rows');
% **** Histogramme du nombre de fois où chaque point apparait
% dans SegmentsCommuns
Histo = histc(iivii,[1:max(iivii)]);
% **** Liste des Points extrêmes
PE=find(Histo==1);
PointsExtremes = iictttii([PE])
PointsExtremesVar = PointsExtremes
PointSecond = 0;
SegmentsOK = [];
Segment1 = 0;
SegmentsCommunsP = SegmentsCommuns
i=1
while isempty (PointsExtremesVar) ~= 1
SegmentsOK = []
startPE = PointsExtremesVar(1,1)
Segment1 = 0;
while isempty (Segment1) ~= 1
Segment1 = SegmentsCommunsP(any(ismember(SegmentsCommunsP,startPE),2),:)
SegmentsCommunsP = SegmentsCommunsP(~all(ismember(SegmentsCommunsP,Segment1),2),:)
SegmentsOK = [SegmentsOK;Segment1]
SegmentsCommunsArray(i).sgtscommuns = SegmentsOK
PointSecond = setdiff(Segment1, startPE)
PointsExtremesVar = setdiff(PointsExtremesVar,startPE)
startPE = PointSecond
end
i = i+1
end |