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!