MATLAB Answers

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