- out=out(:); % just reshape to column vector
- Use k=2*(i-1)+j; % for index vector where i,j ==> a(:,1), a(:,2), respectively.
How i accumulate multiple variables?
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I have an array, where column 1 to 3 are descriptive, and column 4 is the value. For example:
1 1 1 a
1 1 2 b
1 2 1 c
1 2 2 d
2 1 1 e
2 1 2 f
2 2 1 g
2 2 2 h
3 1 1 i
3 1 2 j
3 2 1 k
3 2 2 l
I want to totalize this array by column 3 descriptive value, so the result is this:
1 1 (a+b)
1 2 (c+d)
2 1 (e+f)
2 2 (g+h)
3 1 (i+j)
3 2 (k+l)
I tried with accumarray using as subs columns 1 and 2, and it gives the result i Want, but in a different form:
(a+b) (c+d)
(e+f) (g+h)
(i+j) (k+l)
Please, have any ideas?
0 个评论
采纳的回答
dpb
2020-6-15
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!