cellfun
Apply function to each cell in cell array
Syntax
Description
applies the function A
= cellfun(func
,C
)func
to the contents of each cell of cell
array C
, one cell at a time. cellfun
then
concatenates the outputs from func
into the output array
A
, so that for the i
th element of
C
, A(i) = func(C{i})
. The input argument
func
is a function handle to a function that takes one input
argument and returns a scalar. The output from func
must always
be the same data type to use this syntax. If the function outputs have different
data types, you must set the UniformOutput
name-value argument to
false
. The array A
and cell array
C
have the same size.
You cannot specify the order in which cellfun
calculates the
elements of A
or rely on them being done in any particular
order.
applies A
= cellfun(___,Name,Value
)func
with additional options specified by one or more
Name,Value
pair arguments. For example, to return output
values in a cell array, specify 'UniformOutput',false
. You can
return A
as a cell array when func
returns
values that cannot be concatenated into an array. You can use
Name,Value
pair arguments with the input arguments of
either of the previous syntaxes.
[A1,...,Am] = cellfun(___)
returns multiple
output arrays A1,...,Am
when func
returns
m
output values. func
can return output
arguments that have different data types, but the data type of each output must be
the same each time func
is called. You can use this syntax with
any of the input arguments of the previous syntaxes.
The number of output arguments from func
need not be the same
as the number of input arguments specified by C1,...,Cn
.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced before R2006a
See Also
arrayfun
| spfun
| cell2mat
| structfun
| splitapply