Clear Filters
Clear Filters

Mean of some elements in a matrix

2 views (last 30 days)
A Basu
A Basu on 13 Aug 2017
Commented: A Basu on 14 Aug 2017
I have a matrix A of dimension 25 x 51. I want to calculate the mean of every sequential 5 elements of each row and store them in another matrix. Precisely I want to compute mean(A(1:5,1)), mean(A(6:10,1)) and so on for all columns and save it in another matrix Q of dimension 5 x 51.
Can anyone help me out with the loop??

Accepted Answer

Matt J
Matt J on 13 Aug 2017
Edited: Matt J on 13 Aug 2017
Using SEPBLOCKFUN ( Download ),
result=sepblockfun(yourMatrix,[5,1],'mean');

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!