MATLAB Answers

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

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


Sign in to comment.

Accepted Answer

David Fletcher
David Fletcher on 14 Apr 2018
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.


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)

Sign in to answer this question.