Adding successive cells in a columns
Ältere Kommentare anzeigen
Hi,
I have a table (1x7921). I want to add successive columns. For example add column 1:16, 17:32, 32: 48 etc.
Is there a code that I can used to successively add specific range of columns?
4 Kommentare
Walter Roberson
am 18 Sep. 2020
Could you confirm that you have a table() object that has 7921 variables but only one row?
Isaac Ahenkorah
am 18 Sep. 2020
Walter Roberson
am 18 Sep. 2020
Row 1 is not numeric. You then have 15 numeric rows after that that are to be added to give the yellow result. Then you add the next 16 entries to give the green result. Are you sure you want the yellow to have only 16 numeric entries added together? And as madhan points out, there would be one extra row left over, with a group ending at 7920 . Are you sure you want the last group to be only one number by itself?
It would make a lot more sense to discard that non-numeric first row and add groups of 16 after that.
Isaac Ahenkorah
am 18 Sep. 2020
Akzeptierte Antwort
Weitere Antworten (2)
madhan ravi
am 18 Sep. 2020
Bearbeitet: madhan ravi
am 18 Sep. 2020
Assuming after sir Walter’s comment:
T = TabLe{:, :};
n = numel(TabLe);
t = [TabLe, nan(1, 16 - mod(n, 16))];
Wanted = sum(reshape(t, [], 16), 'omitnan') % nansum() for older versions
2 Kommentare
Isaac Ahenkorah
am 18 Sep. 2020
madhan ravi
am 18 Sep. 2020
Both sir Walter’s answer and my answer should work , once you read the data using readtable()
Isaac Ahenkorah
am 18 Sep. 2020
0 Stimmen
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


