0

I'm looking for a vectorized method of processing k identically-sized N-dimensional arrays provided as an N+1-dimension array in Matlab.

If a general solution is not available, then a specific solution where N = 2, perhaps?

The closest thing I've found is pagefun which applies a function to each 2-dimensional page in a 3-dimensional parameter, but (in a reversal of the common situation) it seems that can only be used with GPU data.

Basically, a vectorized version of

function R = apply(fn, M)
for i = size(M)(1, end)
    R(:,:,..,i) = fn(M(:,:,..,i));
end
Mahmoud Al-Qudsi
  • 28,357
  • 12
  • 85
  • 125
  • Is `bsxfun` what you are looking for? – Ander Biguri Nov 02 '17 at 13:43
  • 1
    The answer depends on the specific function you want to apply. It may be possible to vectorize it or not – Luis Mendo Nov 02 '17 at 14:08
  • I think your question is basically a duplicate of this one: [How can I apply a function to every row/column of a matrix in MATLAB?](https://stackoverflow.com/q/2307249/52738) You're simply extending it to higher dimensions than just the rows (dimension 1) or columns (dimension 2), but the premise is still the same. – gnovice Nov 02 '17 at 14:30

0 Answers0