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

9 ビュー (過去 30 日間)
FARAH ANSARI
FARAH ANSARI 2013 年 2 月 17 日
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....
  2 件のコメント
Jan
Jan 2013 年 2 月 17 日
Please note, that "as soon as possible" is not polite, when you ask volunteers to solve your problem.
FARAH ANSARI
FARAH ANSARI 2013 年 2 月 17 日
SORRY....

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 17 日
編集済み: Azzi Abdelmalek 2013 年 2 月 17 日
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 件のコメント
FARAH ANSARI
FARAH ANSARI 2013 年 2 月 18 日
編集済み: FARAH ANSARI 2013 年 2 月 18 日
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
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 18 日
a=[0 1 0];
idx=find(a)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by