Borrar filtros
Borrar filtros

How do I delete a row based on the based of the first column cell?

1 visualización (últimos 30 días)
For example. If I wanted to delete each row that contained the number 10 in the first column, how can I do that. Essentially is acts like a filter and deletes all the rows with that value.

Respuesta aceptada

the cyclist
the cyclist el 28 de Jun. de 2012
If x is your array,
x(x(:,1)==10,:) = [];
  2 comentarios
Brady Thom
Brady Thom el 28 de Jun. de 2012
Editada: Brady Thom el 28 de Jun. de 2012
Thank you for the speedy response! If you have a second, maybe a little description of what the notation does? I am just trying to learn and be more self sufficient
Ryan
Ryan el 28 de Jun. de 2012
Editada: Ryan el 28 de Jun. de 2012
x(:,1) == 10 returns a logical vector (1 for a 10, 0 otherwise). He's searching all rows (:,) and just the first column (,1).
x(logical vector,:) is locating the row's that have the 10 in the first column from before (dictated by the x(:,1) == 10) and saying select all the columns (,:) of those rows and then delete them by setting them equal to [].

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by