finding overlapping and non-overlapping values in matrix

23 vues (au cours des 30 derniers jours)
NA
NA le 24 Mar 2020
I have
A = [3 16 4 16
3 21 4 21
3 29 3 29
17 27 18 29
25 72 26 72
61 70 61 70
62 63 62 63];
A(1,;) has overlap with A(2,:) and A(3,:)
A(2,:) has overlap with A(1,:) and A(3,:)
A(3,:) has overlap with A(1,:), A(3,:) and A(4,:)
A(4,:) has overlap with A(3,:)
A(5,:), A(6,:) and A(7,:) ---> do not have any intersection to others
result should be
overlapping_rows = [3 16 4 16
3 21 4 21
3 29 3 29
17 27 18 29]
non_overlapping_rows = [25 72 26 72
61 70 61 70
62 63 62 63]

Réponse acceptée

Birdman
Birdman le 24 Mar 2020
Try the following code:
A=[3 16 4 16;3 21 4 21;3 29 3 29;17 27 18 29;25 72 26 72;61 70 61 70;62 63 62 63];
Un=0;
for i=1:size(A,1)
idx{i}=setdiff(find(any(ismember(A,A(i,:)),2)),i);
if i>1
Un=union((idx{i}),Un);
end
end
Un=setdiff(Un,0);
overlapping_rows=A(Un,:)
non_overlapping_rows=A(setdiff(1:size(A,1),Un),:)

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by