FUNCTION REFERENCE

cellfun

Apply a function to each cell of a cell array.

Apply a function to each cell of a cell array.

Syntax

A = cellfun(f, C)

Syntax

A = cellfun('isempty', C)

Syntax

C2 = cellfun(f, C, 'UniformOutput', false)

Calls f once per cell (all cell inputs must have the same size) and collects scalar results in an array, or in cell arrays when UniformOutput is false. The legacy names 'isempty', 'length', 'isreal' and similar are accepted as text.

Example

cellfun(@length, {'ab', 'cde', ''})   % [2 3 0]

Differences from MATLAB: ErrorHandler is not supported.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.