Hello,
Is there a matlab function that allows to take average in an array over 'n' elements:
A=[10 20 30 40]
output=[15 35]
Kind Regards,
Jinang

 採用された回答

Guillaume
Guillaume 2019 年 11 月 12 日

1 投票

Assumming the number of elements of the vectors is a multiple of n, reshape the vector in columns of n rows and take the mean across the rows:
assert(mod(numel(A), n) == 0, 'number of elements of A is not a multiple of n');
result = mean(reshape(A, n, []), 1)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

質問済み:

2019 年 11 月 12 日

回答済み:

2019 年 11 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by