필터 지우기
필터 지우기

How do I measure mean of every 10 data of a vector size 1x1500?

조회 수: 5 (최근 30일)
Klara
Klara 2014년 5월 29일
답변: Jos (10584) 2014년 5월 29일
I have a vector of size 1x1500, whose every 10 values, are of one person (i.e, there are 150 persons).
I should estimate the mean of those 10 values for each person. my script is not working well, any idea?

채택된 답변

David Sanchez
David Sanchez 2014년 5월 29일
A = rand(1,1500); % your data
M = zeros(1,150); % MEAN MATRIX
for k=1:150
M(k) = mean(A(((k-1)*10+k):10*k));
end

추가 답변 (2개)

Jan de Wilde
Jan de Wilde 2014년 5월 29일
Avoiding loops , try:
A = rand(1,1500); % your data
M = mean( reshape( A, 10, 150 ) );

Jos (10584)
Jos (10584) 2014년 5월 29일
% DATA
A = rand(1,1500) ;
N = 10 ;
% ENGINE
M = accumarray((floor((0:numel(A)-1)/N)+1).',A(:),[],@mean) ;
% CHECK
k = 17 ;
isequal(M(k),mean(A(((k-1)*N)+(1:10))))

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by