Filter löschen
Filter löschen

Find the mean of every 5 values in an array

6 Ansichten (letzte 30 Tage)
Lanceric Tse
Lanceric Tse am 13 Aug. 2018
Beantwortet: Geoff Hayes am 13 Aug. 2018
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?

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 13 Aug. 2018
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]))

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by