delete a row with condition
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ha ha
el 5 de Sept. de 2017
Let's say:
A=[ 1 222 ----> labelling "1"
2 555 ----> labelling "2"
3 999 ----> labelling "3"
4 3333 ----> labelling "4"
6 111 ----> labelling "5"
7 5000 ----> labelling "6"
8 2000] ----> labelling "7"
and
B=[ 3; 7];
I wanna delete the row in matrix A in which the first column have the same value as value in matrix B
The result (C) will as follow:
A=[ 1 222
2 555
3 999 ----> delete this row
4 3333
6 111
7 5000 ----> delete this row
8 2000]
Ww have:
C=[ 1 222
2 555
4 3333
6 111
8 2000]
How to do it?
0 comentarios
Respuesta aceptada
Image Analyst
el 5 de Sept. de 2017
Use ismember() to figure out what rows, then [] to extract all but those rows
A=[ 1 222
2 555
3 999 %----> delete this row
4 3333
6 111
7 5000 %----> delete this row
8 2000]
B=[ 3 7];
[ia, ib] = ismember(A(:, 1), B)
A = A(~ia, :)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!