how i average n values in array
5 次查看(过去 30 天)
显示 更早的评论
if i have data a and i want to mean or average every 10 values as 1:10, 2:11, 3:12 and as so on for length of data ?
0 个评论
采纳的回答
Walter Roberson
2016-8-21
mean(reshape(YourData, 10, []))
8 个评论
Andrei Bobrov
2016-8-21
Hi Walter! Small correcting.
cs = cumsum(YourData(:));
moving_average = (cs(10:end) - [0;cs(1:end-10)])/10;
更多回答(2 个)
Star Strider
2016-8-21
‘But i need overlap between the values as 1:10 then from 2:11 and so on’
Use a moving average filter:
Heart_pulse_avg = filter(ones(1,10), 10, Heart_pulse);
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!