MATLAB: simultaneously append to multiple elements of a cell array
I want开发者_开发问答 to append an item to multiple elements of a cell array, at once, in a loop over the items (to be appended). E.g.
nodes(nodesHere,1) = cellfun(@(x)[x items(i)], nodes(nodesHere,1),'UniformOutput',false);
The elements of nodes
might be any array type.
Do you mean something like
x = cell(1,5);
x(1:3) = num2cell([1, 2, 3]);
disp(x);
I know the code won't work for ANY type of array, but it would do the trick if you use mostly numeric data.
精彩评论