I have a function that takes in more than 2 variables
eg.
testFunction = @(x1, x2, x3, x4) x1.*x2.*x3.*x4;
testFunction2 = @(x1, x2, x3) sin(x1.*x2.^x3);
Is there a function available like bsxfun
that allows singleton expansion for functions with more that 2 inputs?
example of bsxfun
binaryTestFunction = @(x1, x2) x1.*x2;
x1 = 9*eye(10);
x2 = 3*ones(10,1);
A = bsxfun(binaryTestFunction , x1 , x2);
Expands the singleton dimension in the x2 vector.
bsxfun
is faster than repmat and also highly iterative and hence I want to know if singleton expansion my testFunction
is possible.