Downsampling by Averaging in Blocks

조회 수: 20 (최근 30일)
Farooq Wahab
Farooq Wahab 2016년 3월 5일
답변: Andrei Bobrov 2016년 3월 5일
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.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 3월 5일
y=[1,2,3,4,5,6,7,8,9,10,11];
out = nanmean(reshape([y(:); nan(mod(-numel(y),4),1)],4,[]));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by