How can I keep the rows where the elements of 1st column are in 2nd column
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
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
Respuestas (1)
Sean de Wolski
el 1 de Jul. de 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))),:)
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!