# 3D indices for particular values in a 3D array

4 visualizaciones (últimos 30 días)
William Sherwin el 8 de Abr. de 2024
Comentada: Stephen23 el 9 de Abr. de 2024
I want to find the 3D indices for particular values in a 3D array. I was expecting to use something like one would use for a 2D array:
>>[row,col] = find(a==8)
So I tried
>>[row,col,page] = find(a==8)
and
>>[row,col,sheet] = find(a==8)
but these just gave nonsense. Surely there is a way to do this?
W.Sherwin@unsw.edu.au
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Stephen23 el 8 de Abr. de 2024
Editada: Stephen23 el 8 de Abr. de 2024
Use IND2SUB:
X = randi(9,4,3,2)
X =
X(:,:,1) = 9 4 1 3 1 8 5 3 7 8 8 4 X(:,:,2) = 7 4 7 7 9 3 6 3 9 8 2 7
[R,C,P] = ind2sub(size(X),find(X==8))
R = 4x1
4 4 2 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
C = 4x1
1 2 3 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P = 4x1
1 1 1 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
##### 2 comentariosMostrar NingunoOcultar Ninguno
William Sherwin el 8 de Abr. de 2024
Thanks Stephen23 ! Bill Sherwin
Stephen23 el 9 de Abr. de 2024
@William Sherwin: please remember to click the accept button of the answer that helped you!

Iniciar sesión para comentar.

### Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by