Info

此问题已关闭。 请重新打开它进行编辑或回答。

converting values in cell array

1 次查看(过去 30 天)
shobhit mehrotra
shobhit mehrotra 2015-10-7
关闭: MATLAB Answer Bot 2021-8-20
I have a cell array A A = [(1 2 3), (5 6 7), (13 14 15)]
I want to convert it so it count sequentially and creates another cell array
B = [(1 2 3), (4 5 6), (7 8 9)]
thanks

回答(1 个)

Kirby Fears
Kirby Fears 2015-10-8
I can't imagine a use-case for this, but here you go:
A = {[1,2,3],[5,6,7],[13,14,15]};
B = cell(size(A));
counter=0;
for iter = 1:numel(A),
B{iter} = counter + (1:numel(A{iter}));
counter=counter + numel(A{iter});
end
Hope this helps.

此问题已关闭。

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by