Используйте встроенную функцию FILTER
%# generate noisy signal
x = sin(0:.1:10*pi);
x = x + 0.5*(rand(1,length(x))-0.5);
%# moving average smoothing
window = 15;
h = ones(window,1)/window;
y = filter(h, 1, x);
%# plot
subplot(211), plot(x), ylim([-1 1]), title('noisy')
subplot(212), plot(y), ylim([-1 1]), title('filtered')
Чтобы решить проблему задержки, попробуйте что-то вроде этого:
s = ceil(window/2);
yy = y(s:end);
n = length(x);
plot(1:n, x, 'b'), hold on, plot(1:n-s+1, yy,'r'), hold off
legend({'noisy' 'filtered'})
альтернативный текст http://img171.imageshack.us/img171/4510/45062995.png