I would like to kindly ask you for the help with the issue of extracting specific values from 3D matrix. I have the variable A(10,10,3) containing the elements 1, 2, 3, and the second variable B(10,10,3) containing pixel values. I need to extract and store the elements from each layer of B which are in the same position as elements 1 from A. Thus, these values should be stored in a cell array (it should contain 3 cells). I was able to perform this task for one 2D matrix, but in the case of 3D matrix I am not able to do that. I would like to kindly ask you for help.