Tuesday, 15 May 2012

Write a MATLAB program to remove the noise component from a corrupted signal by “Smoothing by averaging “ process (i.e. averaging a number of inputs samples around the sample at instant n).



close all;
clc;
m=0:0.1:50;
s=2.*m.*0.9.^m;
n=rand(size(m));
y=s+n;
subplot(2,2,1)
plot(m,s,'k-');
subplot(2,2,2)
plot(m,n,'r');
subplot(2,2,3)
plot(m,y)
k=size(m);

y2=zeros(size(m));
for t=2:k(1,2)

    y2(t)=y(t-1);
 
   
end

y3=zeros(size(m));
y3(size(m))=0;
for t=1:(k(1,2)-1)
   y3(t)=y(t+1);
 
end

avg=zeros(size(m));

for t=1:k(1,2),
   
   avg(t)=(y(t)+y2(t)+y3(t))/3;
 
end
subplot(2,2,4)
plot(m,avg,'r');

0 comments

 
© 2011-2012 ProgrammingBlue
Posts RSS Comments RSS
Back to top