フィルターのクリア

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 ) );
  1 件のコメント
Klara
Klara 2014 年 5 月 29 日
Perfect, this works completely accurate.

サインインしてコメントする。


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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by