MATLAB: Can arrayfun take multi-dimensional arrays as individual arguments

arrayfun

% I have a function that takes three arguments, one of which is a vector:
[output] = function myfun(x,y,[z1 z2])
% I have a 1000×1 array 'x', 1000×1 array 'y', and 1000×2 array 'z'. Can I call this function using arrayfun, such that it will use the 1000 1×2 vectors from 'z' as individual arguments at each call, just as it uses the 1000 individual elements of 'x' and 'y'?
% The only solution I've found is a work-around making using cell arrays and constantly doing cell2mat and mat2cell conversions (very inefficient) …
output = cell2mat(arrayfun(@(x,y,z) myfun(x,y,z,), x, y, mat2cell(z, ones(1000,1), 2));
% Your help is appreciated! Thanks!

Best Answer

Just use a for-loop!
cell2mat/mat2cell/arrayfun are all slow and confusing.