开发者

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.

Is there an equivalent way, relying only on indexing, rather than the relatively more expensive closure used above?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜