averaging successive points in matrix

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.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 10월 23일
편집: Andrei Bobrov 2012년 10월 23일

0 개 추천

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));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

2012년 10월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by