Friday, 24 February 2017

Moving Average Filter in Matlab.

% Here is the Code for Moving average window filter in matlab..

clc
close all
clear all
t=0:0.001:1;
y=sin(2*pi*t);
subplot(311);
 plot(t,y);
title('Original Signal');
noi=randn(size(y));
y=y+noi;
subplot(312);
 plot(t,y);
title('Noisy signal');
w_size=101;
for k=1:length(y)-w_size
    for m=1:w_size
        y(k)=y(k)+y(k+m);
    end
    y(k)=(y(k)/w_size);
end
subplot(313);
 plot(t,y);
 title('Filtered Signal at window size 110');
 axis([0 0.9 -2 2]);



Output:



No comments:

Post a Comment