How to Sum each nth Pages of a Three Dimensional Matrix?

3 次查看(过去 30 天)
Hello all,
I have a matrix with the size of 21x23x246. I would like to sum all arrays of the first, second, third ... and 8th pages and then sum the ninth, 10th ... and 16th pages and so on. In other words, I would like to sum each 8th pages of the matrix.
In the end, I would have a matrix with the dimension of 21x23x31.
Thank you in advance.

采纳的回答

Fangjun Jiang
Fangjun Jiang 2018-9-27
编辑:Fangjun Jiang 2018-9-27
the size of your original matrix, say A, needs to be 21x23x248, right?
sz=size(A)
B=reshape(A,sz(1),sz(2),8,[]);
squeeze(sum(B,3))
  7 个评论
Fangjun Jiang
Fangjun Jiang 2022-11-22
sz=size(A), A is a 21x23x246 matrix, so sz(1) is 21, sz(2) is 23.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by