Borrar filtros
Borrar filtros

extract rows of a matrix

1 visualización (últimos 30 días)
RuiQi
RuiQi el 19 de Jul. de 2016
Respondida: Star Strider el 19 de Jul. de 2016
I have a matrix with many rows and 6 columns. I want to extract the rows whose 6th column == 1. How can I do this ? And what is this 'technique' called ? Logical indexing ? Find ? I keep forgetting how to do this. I need to refer to the documentation but im not sure what to google.
  1 comentario
Stephen23
Stephen23 el 19 de Jul. de 2016
Logical indexing is faster than find.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 19 de Jul. de 2016
Editada: Stephen23 el 19 de Jul. de 2016

Más respuestas (1)

Star Strider
Star Strider el 19 de Jul. de 2016
This works:
M = randi(9, 20, 6);
M_extract = M(M(:,6) ==1, :);

Categorías

Más información sobre Resizing and Reshaping Matrices 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