Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

converting values in cell array

1 Ansicht (letzte 30 Tage)
shobhit mehrotra
shobhit mehrotra am 7 Okt. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

Kirby Fears
Kirby Fears am 8 Okt. 2015
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.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by