Hi everybody,
I'm trying to sum values of a timetable based on start and endposition from another array. The results will be inserted in the timetable in a new column.
It works with loops but the size of my table makes it quite slow and since I use vectorization for other purposes, and it is quite fast, I only assume that there is a way to achive it with rowfun for example. But I tried several scenarios but it does not work.
Here is what I try to achieve through an example .
start position array : Start=[1;3;6]
stop position array : Stop=[2;5;8]
Values from timetable: Values=[10;20;10;30;50;40;80;20;10]
I want an output vector with the sum based on start and stop position, so a 3X1.
For example:
First result: sum of Values from position 1 to 2: 10+20=30
Second result: sum of Values from position 3 to 5: 10+30+50=90
Third result: sum of Values from position 6 to 8: 40+80+20=140
So, how to achieve that simple operation with rowfun?
Thanks.
Michel Rathé
Best Answer