averaging 20 values within 1000 data points

조회 수: 5 (최근 30일)
PIRIL
PIRIL 2015년 11월 2일
댓글: PIRIL 2015년 11월 2일
Hello all,
I have a 27x 1000 matrix and I want to avarage the numbers between 1-20, 21-40, 41-60 .......... 981-1000 in each row.
Could anyone help me about this ?
Many thanks

채택된 답변

Image Analyst
Image Analyst 2015년 11월 2일
If you have the Image Processing Toolbox (use "ver" to check), then you can use blockproc():
myData = rand(27,1000); % Sample data
% Define the mean function to be used with blockproc.
myMeanFunction = @(block_struct) mean(block_struct.data);
% Get the means by each 1-by-20 block.
blockMeans = blockproc(myData, [1 20], myMeanFunction)

추가 답변 (1개)

Torsten
Torsten 2015년 11월 2일
average=zeros(27,50);
for i=1:27
for j=1:50
average(i,j)=mean(A(i,(20*(j-1)+1):(20*j)));
end
end
Best wishes
Torsten.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by