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

6 views (last 30 days)
I have a value inside a 26x7x101 matrices and would like to find its i j k locations

Accepted Answer

David Fletcher
David Fletcher on 14 Apr 2018
[~,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 Comments
Walter Roberson
Walter Roberson on 14 Apr 2018
[i, j, k] = ind2sub( size(YourMatrix), find(YourMatrix == value, 1) );
remove the ", 1" if you want all of the occurrences.
Walter Roberson
Walter Roberson on 14 Apr 2018
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!