MATLAB Function Reference Previous page   Next Page
cellfun

Apply function to each element in cell array

Syntax

Description

D = cellfun('fname', C) applies the function fname to the elements of the cell array C and returns the results in the double array D. Each element of D contains the value returned by fname for the corresponding element in C. The output array D is the same size as the cell array C.

These functions are supported:

Function
Return Value
isempty
true for an empty cell element
islogical
true for a logical cell element
isreal
true for a real cell element
length
Length of the cell element
ndims
Number of dimensions of the cell element
prodofsize
Number of elements in the cell element

D = cellfun('size', C, k) returns the size along the kth dimension of each element of C.

D = cellfun('isclass', C, 'classname') returns logical 1 (true) for each element of C that matches classname. This function syntax returns logical 0 (false) for objects that are a subclass of classname.

Limitations

If the cell array contains objects, cellfun does not call overloaded versions of the function fname.

Examples

Consider this 2-by-3 cell array:

cellfun returns a 2-by-3 double array:

See Also

isempty, islogical, isreal, length, ndims, size


Previous page  celldisp cellplot Next page

© 1994-2005 The MathWorks, Inc.