finding overlapping and non-overlapping values in matrix

21 ビュー (過去 30 日間)
NA
NA 2020 年 3 月 24 日
回答済み: Birdman 2020 年 3 月 24 日
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]

採用された回答

Birdman
Birdman 2020 年 3 月 24 日
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),:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by