How to average the data in a large text file ?

3 ビュー (過去 30 日間)
Add
Add 2016 年 3 月 31 日
編集済み: Jan 2016 年 3 月 31 日
I have the data in one column and 720 rows, how do i get the average of each consecutive numbers ? Example, If I have, [1,2,3,4,5,6,7,8,9,10], I want to take average of 1&2, 3&4, 5&6, 7&8, and 9&10. How to do it ?
Thanks, add.

採用された回答

Orion
Orion 2016 年 3 月 31 日
Hi,
Here's one way to do it :
col = (1:10)';
mymeans = 0.5*(col(1:2:end-1) + col(2:2:end))

その他の回答 (1 件)

Jan
Jan 2016 年 3 月 31 日
編集済み: Jan 2016 年 3 月 31 日
Or:
data = 1:10;
result = mean(reshape(data, 2, []), 1);

カテゴリ

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