arrayfun
Apply a function with scalar inputs and a scalar output to each of the elements of an array or to each set of elements of a set of arrays.
y=arrayfun(func,x,a,b,c,d,...)
Inputs
func A function which returns one output for a set of one or more scalar inputs.
{x, a, b, c,...} Arrays of the same size or scalars.
Outputs
y The result of applying the function func to each set of elements of the input arrays.


Description
The output is defined by y[i]=func(xi,ai,bi,ci,di,...), i=1:n where ai=a[i] if a is an array and ai=a otherwise. Here n is the number of elements in each of the non-scalar inputs.
Example
>>a=[1 2 ; 3 4]
>>b=[-1 10; 2,5];
>>c=0
>>arrayfun(@(x,y,z)max(x,y,z),c,a,b)
          1         10
          3          5
>>c=8
>>arrayfun(@(x,y,z)max(x,y,z),a,b,c)
          8         10
          8          8