Group-wise mean in multi-dimensional array (part II)

I have a 256*256*515 double array. It represents 515 images by the dimension of 256*256. Along the 515 axis, every 5 images belong to the same group. I would like to take the element-wise block mean every 5 elements such that my cell array may be condensed into 256*256*103. How may I do that?
I had success applying reshape function to 2D arrays, but am not quite sure how to proceed in this case.
Thank you very much!

 채택된 답변

the cyclist
the cyclist 2015년 10월 14일
This works, right?
M = rand(256,256,515); % Use your actual data here
M_r = reshape(M,256,256,103,5);
M_r_mean = mean(M_r,4);

댓글 수: 3

Brian
Brian 2015년 10월 14일
Ah! I think it worked beautifully. I really appreciate your help!
dpb
dpb 2015년 10월 14일
Ah-so, cycler! Wasn't thinking of using another dimension earlier. That's very good; will have to remember that going forward.
Brian
Brian 2015년 10월 15일
Thank you both!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2015년 10월 14일

댓글:

2015년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by