Sum e columns together without a for loop.
显示 更早的评论
So I let say there a matrix like this
b = [1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9]
I want to change b into a matrix like this
b = [6 15 24; 6 15 24; 6 15 24]
So I'm add summing up the columns, but only 3(e) at a time, leaving me with a matrix that used to be nxm but is now nx(m/e).
Currently, I'm doing this with a for loop where I just take every 3 columns together to make a new column and update the field of a preallocated matrix of size nx(m/3). However, I realize that I need to make it work for any e(not just 3) and because of this, and the large datasets I will be dealing with(both n and m are large), I need to be able to do this without a for loop.
Is there some built in function that will help me? I've tried going through the documentation but I can't seem to find anything that will work.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!