Finding the mean value of a set.
13 ビュー (過去 30 日間)
古いコメントを表示
Let's say that I have a set of numbers, for example x= [1 2 4 6 2 7 8 4 5 7 8 9]. I want to calculate the mean value for every 3 numbers. In this case first 1 2 4 , then 6 2 7 and so on. How do I do? should I use any functions?
in fact I have a column containing 180000 numbers. and I want to calculate the mean value for every 50 numbers. Totally 180000/50=3660 mean values. I would appreciate every suggestion.
0 件のコメント
回答 (1 件)
Steven Lord
2022 年 11 月 9 日
Original data:
x= [1 2 4 6 2 7 8 4 5 7 8 9]
Reshape it into a 3-by-whatever matrix. I'll let MATLAB figure out what "whatever" is.
A = reshape(x, 3, [])
Take the mean in dimension 1 (down the columns.)
m = mean(A, 1)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!