I wanna know, how can I get the position of a given value in a matrix

1 visualizzazione (ultimi 30 giorni)
As......
A =[1 0 0; 0 1 0]
Tell me, how to find the position of '1' and print the position...
Mind telling me...
Thankyou....

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 17 Feb 2013
Modificato: Azzi Abdelmalek il 17 Feb 2013
A =[1 0 0; 0 1 0]
idx=find(A==1) % Linear index
% The linear index of your matrix is, in this order
% [1 3 5
% 2 4 6]
%or
A =[1 0 0; 0 1 0] % Matrix indices
[ii,jj]=find(A)
  3 Commenti
FARAH ANSARI
FARAH ANSARI il 18 Feb 2013
Modificato: FARAH ANSARI il 18 Feb 2013
Sir, It is giving the positions for all rows But I wanna know , if I entered the row like
[0 1 0]
it gives the position = 2

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by