You are on page 1of 3

clear;

x=[0 1 2];
h=[5 4 6];
i=length(x);
j=length(h);
ht=[zeros(1,i-1) h zeros(1,i-1)];
for n=0:(j+i-2)
sig=0;
for k=0:i-1
sig=sig+x(k+1)*ht((n+1)-(k+1)+i);
end
y(n+1)=sig;
end
y
subplot(3,1,1);
stem(x);
subplot(3,1,2);
stem(h);
subplot(3,1,3);
stem(y);
clear;
t=0:1/100:1;
x=sin(2*pi*10*t)+0.3*randn(1, length(t));
n=-7.9:0.5:7.9;
h=sin(4*pi*n/8)./(4*pi*n/8)
i=length(x);
j=length(h);
ht=[zeros(1,i-1) h zeros(1,i-1)];

for n=0:(j+i-2)
sig=0;
for k=0:i-1
sig=sig+x(k+1)*ht((n+1)-(k+1)+i);
end
y(n+1)=sig;
end
y
subplot(3,1,1);
stem(x);
subplot(3,1,2);
stem(h);
subplot(3,1,3);
stem(y);
clear;
t=0:1/100:1;
x=sin(2*pi*10*t)+0.3*randn(1, length(t));
n=-7.9:0.5:7.9;
h=sin(4*pi*n/8)./(4*pi*n/8)
i=length(x);
j=length(h);
ht=[zeros(1,i-1) h zeros(1,i-1)];

for n=0:(j+i-2)
sig=0;
for k=0:i-1
sig=sig+x(k+1)*ht((n+1)-(k+1)+i);
end
y(n+1)=sig;
end
y
subplot(3,1,1);
stem(x, 'g'); hold on
plot(x,'k')
subplot(3,1,2);
stem(h,'g');hold on
plot(h,'k')
subplot(3,1,3);
stem(y,'g' );hold on
plot(y,'k')

You might also like