cellfun
cellfun(fh,c1,c2,...) applies function handle fh to cells c1, c2, ...
cellfun(fh,c1,c2,..., 'UniformOutput', op) with op set to:
cellfun(fh,c1,c2,..., 'UniformOutput', op) with op set to:
- true (default): indicates that all inputs are uniform and susceptible to be concatenated
- false: returns a cell array output
Examples
>> c = {[1 2] 1:10 [5 20 40]}# [1x2 double][1x10 double][1x3 double] >> sums = cellfun(@sum,c)# 3 55 65 >>% function handle with multiple input arguments
sizes = cellfun(@(x) size(x, 2),c)# 2 10 3
>> c ={[-1 3; -5 -9] [1; -4; 0] -110}# [2x2 double][3x1 double][-110] >> absvalue = cellfun(@abs, c, 'UniformOutput', false)# [2x2 double][3x1 double][110] >> absvalue{1}# 1 3 5 9