how to find the row index of specific vector in a matrix

221 visualizaciones (últimos 30 días)
d d
d d el 7 de Abr. de 2019
Comentada: AKASH BHOYAR el 23 de Mayo de 2022
Hi everyone, suppose there's a marix [2 0;-2 1;2 3], I want find the row index of [-2 1], i.e., [-2 1] is on the second row of [2 0;-2 1;2 3]. how to realize it in matlab? Many thanks!

Respuesta aceptada

Star Strider
Star Strider el 7 de Abr. de 2019
Try this:
A = [2 0;-2 1;2 3];
RowIdx = find(ismember(A, [-2 1],'rows'))
producing:
RowIdx =
2
  2 comentarios
Elizabeth Thompson
Elizabeth Thompson el 11 de Mzo. de 2022
How would I do this if the vector I am looking for is a subset of A? i.e. If A is a matrix with three columns, and I want to find which row a 1x2 array x is in of A? idx=find(ismember(A,x,'rows')) obviously wouldn't work here, but is there a way to do this still using the find(ismember()) command?
AKASH BHOYAR
AKASH BHOYAR el 23 de Mayo de 2022
@Star Strider Very Helpful. Thanks 3000!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings 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!

Translated by