averaging successive points in matrix
2 views (last 30 days)
Show older comments
I am new to matlab and I want to average a matrix M(26x149) in such away that 9 successive data points in the second dimension are averaged to have M(26,17) data. The division of 149/9 may not be exact but I want 16 data plus the remaining 5 points are also averaged to make the total data M(26,17).
here is the script I tried
a= 1:9:length(M)
MM=mean(M(:,a))
but this doesn't solve my problem
Any help is highly appreciated.
0 Comments
Accepted Answer
Andrei Bobrov
on 23 Oct 2012
Edited: Andrei Bobrov
on 23 Oct 2012
M = randi(100,26,149);
n = 9;
[a,b] = size(M);
out = squeeze(nanmean(reshape([M,nan(a,mod(-b,n))],a,n,[]),2));
variant with use function blockproc from Image Processing Toolbox
out = blockproc(M,[size(M,1) n],@(x)mean(x.data,2));
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!