Conditional running summation in an array
显示 更早的评论
I have imported an array (T) with data associated to multiple reoccurring, unique numeric variables. I would like to sum each column that has the same numeric variable, However, I can't seem to figure out how to combine the sum function with a for loop. Any help is appreciated! Thank you.
In the below example, the unique variables are in column 1. I am attempting to create a new table where the unique numeric variable stays the same, and all the remaining columns are summed exclusively for that variable. The number of columns in the output table will remain the same so the sum will be in the 1st dimension. Eg.SUM(T,1) T = [2,0,0,0,0,0,1.66;2,32.96,0,0,0,0,0;1,75.61,0,0,0,0,0;1,0,0,5.94,0,0,0;1,9.83,0,0,0,0,0;1,0,0,0,42.32,0,0;1,0,5.93,0,0,0,0;1,0,0,0,0,0.92,0;1,140.32,0,0,0,0,0;1,0,0,0,70.98,0,0;5,0,0,0,7.54,0,0;5,322.43,0,0,0,0,0;5,6367.19,0,0,0,0,0;5,0,0,8.44,0,0,0];
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!