Sum of defined portion of a 3D matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to sum different layers of a 3D matrix, but I don't know an easy way of doing it. Basically what I would like to do is this:
matrix1=sum(timematrix(:,:,1:3))
"timematrix" is a 1x1000x5 matrix and I would like to compute the sum of the first 3 layers. Using the following command works:
matrix1=timematrix(:,:,1)+timematrix(:,:,2)+timematrix(:,:,3)
Thanks in advance!
0 个评论
采纳的回答
Walter Roberson
2015-9-22
matrix1 = sum(timematrix(:,:,1:3), 3);
1 个评论
Stephen23
2015-9-22
This is explained perfectly in the documentation:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!