How can I keep the rows where the elements of 1st column are in 2nd column
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
I have a edge list as below:
1 2
1 3
1 9
2 1
2 3
3 1
3 2
3 4
3 9
I need in matlab rows where 1st column values are present in 2nd column. i.e. From the above I need rows in which 1st column values(1,2,3) are present in 2nd column(i.e. keep the rows where 2nd column too has values 1,2,3 and the rest remove. So finally it should be:
1 2
1 3
2 1
2 3
3 1
3 2
Antworten (1)
Sean de Wolski
am 1 Jul. 2014
M=[1 2
1 3
1 9
2 1
2 3
3 1
3 2
3 4
3 9];
Mpc = M(ismember(M(:,2),unique(M(:,1))),:)
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!