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
0 个评论
采纳的回答
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
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
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 Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!