Let's say I have a function f(vec) which takes as input a vector (array) of size 3. I have a matrix M of size 100 x 100 x 3. Is there a way I can somehow apply f to every cell of M, outputting a matrix N of size 100 x 100? For example, N(10,20) would equal
f( M(10,20,1), M(10,20,2), M(10,20,3) ) Obviously I could use a for loop, but I feel like this should be vectorizable.