Effacer les filtres
Effacer les filtres

finding the position of a number?

1 vue (au cours des 30 derniers jours)
Sivakumaran Chandrasekaran
a=[1 2 3;4 5 6] b=2 i should compare b with all elements of a and to find the corresponding position in a ... e.g., the answer should be (1,2). what command or what method should i use

Réponse acceptée

Youssef  Khmou
Youssef Khmou le 27 Mar 2013
Modifié(e) : Youssef Khmou le 27 Mar 2013
try this way
a=[1 2 3;4 5 6]; b=2;
[x,y]=find(a==b);
A=[x,y];
  1 commentaire
Image Analyst
Image Analyst le 27 Mar 2013
I wouldn't call it x,y - I'd call it row, column. Because usually x is the column (horizontal location), not the row as you have it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by