Vous êtes sur la page 1sur 1

%superposition principle

n=0:1:40;
a=2; b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
num=[0.634 0 0.634];
den=[1 0 -0.268];
i.c=[0 0];
y1=filter(num,den,x1,i.c);
y2=filter(num,den,x2,i.c);
y=filter(num,den,x,i.c);
yt=a*y1+b*y2;
subplot(3,1,1);
stem(n,y,'red');grid on;xlabel('time');
ylabel('amplitude');title('a*x1[n]+b*x2[n]');
subplot(3,1,2);
stem(n,yt,'magenta');grid on;xlabel('time');
ylabel('amplitude');title('a*y1[n]+b*y2[n]');
%impulse response
n=0:1:40;
p=impz(num,den,n);
subplot(3,1,3);
stem(p,'blue');grid on;title('impulse response');
%linearly time invariant system
n=0:1:40; t=0:1:50;
a=2; b=-3;D=10;
x=a*cos(2*pi*0.1*n)+b*cos(2*pi*0.4*n);
num=[0.5 -0.5];
den=1;
xd=[zeros(1,D) x];
i.c=0;
y=filter(num,den,x,i.c);
yd=filter(num,den,xd,i.c);
subplot(5,1,1);
stem(n,x,'red');grid on;xlabel('time');
ylabel('amplitude');title('x[n]');
subplot(5,1,2);
stem(n,y,'blue');grid on;xlabel('time');
ylabel('amplitude');title('y[n]');
subplot(5,1,3);
stem(t,xd,'cyan');grid on;xlabel('time');
ylabel('amplitude');title('x[n-10]');
subplot(5,1,4);
stem(t,yd(1:51),'magenta');grid on;xlabel('time');
ylabel('amplitude');title('y[n-10]');
%impulse response
n=0:1:40;
p=impz(num,den,n);
subplot(5,1,5);
stem(p,'blue');grid on;title('impulse response');

Vous aimerez peut-être aussi