Moving Average Filter in MATLAB | DSP

Prerequisite:
Random sequence Generation in MATLAB | Part 1


Code:

clc
clear all
close all
t=0:0.11:20;
x=sin(t);
n=randn(1,length(t));
x=x+n;
a=input('Enter the no.:');
t2=ones(1,a);
num=(1/a)*t2;
den=[1];
y=filter(num,den,x);
plot(x,'b');
hold on;
plot(y,'r','linewidth',2);
legend('Noisy signal','Filtered signal');



No comments