Extract and average from matrix
Show older comments
Hello all, Im trying to extract every 7 rows of a matrix and average them (mean). As an example:
4.20
4.10
4.10
4
3.90
3.80
NaN
3.80
3.90
3.90
3.70
3.60
3.60
3.40
3.40
3.30
3.30
3.30
3.30
3.10
3.10
What code would i need to take the first 7 rows and average them, and to continually do this for the matrix i.e. average of rows 1:7 8:14 15:21
Thanks in advance.
Accepted Answer
More Answers (1)
Image Analyst
on 4 Dec 2018
Try reshape()
vec = (1 : 70)' % Sample data
m2d = reshape(vec, 7, [])
means7 = mean(m2d, 1)
Categories
Find more on Get Started with MATLAB 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!