Downsampling by Averaging in Blocks
17 views (last 30 days)
Show older comments
Farooq Wahab
on 5 Mar 2016
Answered: Andrei Bobrov
on 5 Mar 2016
Hello, I would like to downsample data simulated at 200 Hz to 50 Hz by averaging blocks of 4 and plot it versus time. For example, if y=[1,2,3,4,5,6,7,8,9,10,11,......], I would like to do averages of (1,2,3,4), then (5,6,7,8), and so and plot it versus t=[0:1/50:60], so that the downsampled data appears to be sampled at 50 Hz. The MATLAB downsample function seems to downsample by removing the data points. http://www.mathworks.com/help/signal/ref/downsample.html
Thanks.
0 Comments
Accepted Answer
Andrei Bobrov
on 5 Mar 2016
y=[1,2,3,4,5,6,7,8,9,10,11];
out = nanmean(reshape([y(:); nan(mod(-numel(y),4),1)],4,[]));
0 Comments
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!