Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Parthu P
Parthu P le 22 Nov 2019
Hi, I have 300x20 matrix (A). How to calculate average of every 3 consecutive rows of each column to have output matrix B (100x20)?

Réponse acceptée

Ridwan Alam
Ridwan Alam le 22 Nov 2019
B = (A(1:3:end,:)+A(2:3:end,:)+A(3:3:end,:))/3

Plus de réponses (2)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 22 Nov 2019
solution:
mean100x20=reshape(mean(reshape(A,3,[])),100,[])

Parthu P
Parthu P le 22 Nov 2019
Thank you both.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by