Extract 3D cells with nonzero elements, from a 3D cell array.
Mostrar comentarios más antiguos
Hi guys! I have binary masks saved in 3D arrays (e.g. Mask(:,:,40), see attached Matlab file) and I want to extract only the 3D cell arrays which contain nonzero elements in a sequential order (e.g. if these are 20, then NMask(:,:,20)). Any ideas would be much appreciated.
1 comentario
Stephen23
el 12 de Sept. de 2016
See Guillaume's answer for a much simpler solution.
Respuesta aceptada
Más respuestas (1)
Guillaume
el 12 de Sept. de 2016
Well, if you want nice and concise:
filteredmask = Combinedmask(:, :, any(any(Combinedmask, 1), 2))
No need for cell arrays, loops, ifs, etc., just one line.
1 comentario
George Papas
el 12 de Sept. de 2016
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!