how to remove rows from an array containig elements from another array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
DuckDuck
el 19 de Nov. de 2014
Suppose i have a matrix of
a=[1,2;
1,3;
1,4;
2,12;
2,15;
5,7;
5,8;
6,98;
6,99;
7,8;
7,9;
7,11;
9,14;
9,16;
12,18;
14,20;
20,35;
98,102;
99,204;
204,300];
I want to remove rows containing elements from array b, do some manipulations than remove elements of c do smth and than d.
b=[1,2,3,4,12,15,18]
c=[5,7,8,9,14,16,20,35]
d=[6,98,99,102,204,300]
is there a fast and wasy way to do that with built in matlab functions
0 comentarios
Respuesta aceptada
Guillaume
el 19 de Nov. de 2014
Editada: Guillaume
el 19 de Nov. de 2014
Use the negation of ismember to get the elements of a column of a that are not in b. If you want to do that for both columns of a, you have to call ismember twice.
col1notinb = ~ismember(a(:, 1), b);
col2notinb = ~ismember(a(:, 2), b);
awithoutb = a(col1notinb & col2notinb, :);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!