MATLAB Answers

How to average the data in a large text file ?

14 views (last 30 days)
Add
Add on 31 Mar 2016
Edited: Jan on 31 Mar 2016
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.

  0 Comments

Sign in to comment.

Accepted Answer

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

  0 Comments

Sign in to comment.

More Answers (1)

Jan
Jan on 31 Mar 2016
Edited: Jan on 31 Mar 2016
Or:
data = 1:10;
result = mean(reshape(data, 2, []), 1);

  0 Comments

Sign in to comment.

Sign in to answer this question.


Translated by