There are two ways to achieve it:
You can set 'UniformOutput' to false. Then the result is an array of cells.
result = arrayfun(@(x)(1:x),array,'UniformOutput',false);
But there is a good trick I found today, the function itself can return the cell. This eliminates the need to type 'UniformOutput',falseeach time.
result = arrayfun(@(x){1:x},array)
, @(X)({1:x}), @(X){1:x}
(1): @Jonas, , () , . , @(x) x+1 .
(2): UniformOutput,false. , .