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

1 次查看(过去 30 天)
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....

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by