Find the mean of every 5 values in an array

3 ビュー (過去 30 日間)
Lanceric Tse
Lanceric Tse 2018 年 8 月 13 日
回答済み: Geoff Hayes 2018 年 8 月 13 日
Hi, so I have an array of double
b=[ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0]
How do I obtain the mean of every 5 values?

採用された回答

Geoff Hayes
Geoff Hayes 2018 年 8 月 13 日
Lanceric - try using reshape to change your array from a 1x20 to a 5x4 array and then compute the mean from that. For example,
mean(reshape(b,[5,4]))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by