How to find a location of a specific value inside a matrices that is 26x7x101 of length

7 次查看(过去 30 天)
I have a value inside a 26x7x101 matrices and would like to find its i j k locations

采纳的回答

David Fletcher
David Fletcher 2018-4-14
[~,loc]=ismember(matrixName,value)
[i,j,k]=ind2sub([26,7,101],find(loc,1))
The above will find the first specified value in the matrix and return its i,j,k indices. The code would need some small modification if the value wasn't unique and you needed the indices of all occurrences of the specified value.
  2 个评论
Walter Roberson
Walter Roberson 2018-4-14
[i, j, k] = ind2sub( size(YourMatrix), find(YourMatrix == value, 1) );
remove the ", 1" if you want all of the occurrences.
Walter Roberson
Walter Roberson 2018-4-14
Caution: you need to change strategy a bit if the values are floating point and the value you are looking for has not been directly copied out of the matrix.

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by