Find index in matrix

2 次查看(过去 30 天)
Rafael Luque
Rafael Luque 2019-8-5
I have the next matrix:
A =
0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 2 2
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 1 2
1 2 0
1 2 1
1 2 2
Is it possible to know the matrix index of a (x,y,z) value? For example (x,y,z) = (0,2,0) would be index=7:
A(7,:)= (0,2,0)

回答(1 个)

the cyclist
the cyclist 2019-8-5
编辑:the cyclist 2019-8-5
[tf,idx] = ismember([0 2 0],A,'rows')
The output idx gives the row index. See ismember for details.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by