finding overlapping and non-overlapping values in matrix

22 visualizaciones (últimos 30 días)
NA
NA el 24 de Mzo. de 2020
Respondida: Birdman el 24 de Mzo. de 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]

Respuesta aceptada

Birdman
Birdman el 24 de Mzo. de 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),:)

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by