How to calculate cumulative average of every n values in a matrix?

조회 수: 5 (최근 30일)
Parthu P
Parthu P 2019년 11월 22일
답변: Parthu P 2019년 11월 22일
Hi, I have 300x20 matrix (A). How to calculate average of every 3 consecutive rows of each column to have output matrix B (100x20)?

채택된 답변

Ridwan Alam
Ridwan Alam 2019년 11월 22일
B = (A(1:3:end,:)+A(2:3:end,:)+A(3:3:end,:))/3

추가 답변 (2개)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 22일
solution:
mean100x20=reshape(mean(reshape(A,3,[])),100,[])

Parthu P
Parthu P 2019년 11월 22일
Thank you both.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by