Finding an array of numbers in an array

2 visualizaciones (últimos 30 días)
MiauMiau
MiauMiau el 30 de Sept. de 2018
Comentada: Star Strider el 30 de Sept. de 2018
Hi
I have the attached coords_17 array, which is 2092 x 3 dimensional. Within this array, I want to find say the row which contains the coordinates [44, -30, 54]. However, the following commands fails somehow:
find(coords_17 == [44, -30, 54])
How can I find the relevant coordinates correctly? Many thanks

Respuesta aceptada

Star Strider
Star Strider el 30 de Sept. de 2018

I would use the ismember (link) function.

Try this:

target = [44, -30, 54];
Lidx = ismember(coords_17, target, 'rows');
row_number = find(Lidx)
row_number =
     2
  4 comentarios
MiauMiau
MiauMiau el 30 de Sept. de 2018
thx
Star Strider
Star Strider el 30 de Sept. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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