필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
ehsan
ehsan 2018년 9월 27일
댓글: Simbarashe Chidzambwa 2022년 11월 23일
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.
Simbarashe Chidzambwa
Simbarashe Chidzambwa 2022년 11월 23일
Thank you Fangjun.

댓글을 달려면 로그인하십시오.

추가 답변 (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