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

2 次查看(过去 30 天)
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
solution:
mean100x20=reshape(mean(reshape(A,3,[])),100,[])

Parthu P
Parthu P 2019-11-22
Thank you both.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by