Finding ALL the indicies that match a certain value

3 visualizaciones (últimos 30 días)
Abbi Hashem
Abbi Hashem el 10 de Dic. de 2018
Respondida: Star Strider el 10 de Dic. de 2018
Suppose I have a variable A= 4
and I have a vector B = [ 3 5 4 6 4 6 7 ]
I want to find the index of B that match A
that is , a vector with [ 3 , 5 ] since they are the third and 5th

Respuestas (1)

Star Strider
Star Strider el 10 de Dic. de 2018
Use the find function:
A = 4;
B = [ 3 5 4 6 4 6 7 ];
idx = find(B == A)
producing:
idx =
3 5

Categorías

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