Ass 2
Ass 2
Ass 2
1.c
Linearity:
N=1:50;
x1=sin(2*pi*0.02*N);
x2=sin(2*pi*0.01*N);
y1=filter(B,A,x1);
y2=filter(B,A,x2);
y3=filter(B,A,x1+x2);
AY=[-5 5];
subplot(313);stem(N,y3-(y1+y2));ylim(AY);title('difference-3');grid on;
Time Inv:
%B=[0.5 -2 5];A=[1];
N=1:50;
x1=sin(2*pi*0.02*N);
y1=filter(B,A,x1);
y1=[0 y1];
y2=filter(B,A,[0 x1]);
N=1:51;
AY=[-5 5];
subplot(313);stem(N,y2-y1);ylim(AY);title('difference tiv-3');grid on;
2.
Linearity:
N=1:50;
x1=sin(2*pi*0.02*N);
x2=sin(2*pi*0.01*N);
y1(1:50)=A*x1(1:50)+ B;
y2(1:50)=A*x2(1:50)+ B;
x3=x1+x2;
y3(1:50)=A*x3(1:50)+ B;
N=1:50;
N=1:50;
subplot(313);stem(N,y3-(y1+y2));title('difference-lin-q2');grid on;
Time Inv:
N=1:50;
x1=sin(2*pi*0.02*N);
y1=A*x1+ B;
y1=[0 0 y1];
x1=[0 0 x1];
y2=A*x1+ B;
N=1:52;
subplot(313);stem(N,y2-y1);title('difference-tiv-q2');grid on;
3.
Lin:
N=1:50;
x1=sin(2*pi*0.02*N);x1=[0 x1];
x2=sin(2*pi*0.01*N);x2=[0 x2];
y1=[zeros(1,51)];
y2=y1;y3=y1;%y4=y1;
y1(2:51)=A*y1(1:50)+ B*x1(2:51);
y2(2:51)=A*y2(1:50)+ B*x2(2:51);
x3=x1+x2;
y3(2:51)=A*y3(1:50)+ B*x3(2:51);
%N=1:50;
% y4(N+1)=A*y4(N)+ B*x1(N+1);
% y4=[0 0 y4];
% y5(N+3)=A*y5(N+1)+ B*x2(N+3);
N=1:51;
ylabel('amplitude');grid on;
Ay=[-5 5];
subplot(313);stem(N,y3-y1-y2);title('difference-lin-q3');grid on;
Time Inv:
B=5;
A=3;
N=1:50;
x1=sin(2*pi*0.02*N);x1=[0 x1];
%x2=sin(2*pi*0.01*N);x2=[0 x2];
y3=[zeros(1,51)];
y2=y3;y1=y3;
N=1:50;
y1(N+1)=A*y1(N)+ B*x1(N+1);
y1=[0 0 y1];
y2(N+3)=A*y2(N+1)+ B*x2(N+3);
N=1:53;
ylabel('amplitude');grid on;
ylabel('amplitude');grid on;
Ay=[-5 5];
subplot(313);stem(N,y2-y1);title('difference-tiv-q3');grid on;
4.a
clc;
clear all;
close all;
x=[1 2 3 4];
h=[1 1 1 1];
N=length(x)+length(h)-1;
y1=conv(x,h);
subplot(311) ;
stem(x) ;
subplot(312) ;
stem(h) ;
subplot(313) ;
stem(y1) ;
4.b
clc;
clear all;
close all;
x=[3 1 2 1];
n1 = -2:1:1 ;
h=[1 1 1];
n2=0:1:2 ;
n=-2:1:8 ;
N=length(x)+length(h)-1;
x1=[x zeros(1,N-length(x))] ;
h1=[h zeros(1,N-length(h))] ;
y=[zeros(1,N)] ;
y=conv(x1,h1);
ax=[-2 3] ;
subplot(311) ;
stem(n1,x) ;
subplot(312) ;
stem(n2,h) ;
subplot(313) ;
stem(n,y) ;
xlim(ax) ;
5.i
clc;
clear all ;
close all ;
for m=1:7
y(m)=sum(x(1:N).*hrev(1:N));
hrev=[zeros(1) hrev];
subplot(312),stem(-3:3,hrev(1:N));
subplot(313),stem(0:N-1,y)
pause(1);
end
5.ii
6.
clc;
clear all;
close all;
x=[3,2,1,1];
n1=-2:1:1;
l1=length(x);
h=[1,1,1];
n2=0:1:2;
l2=length(h);
l3=l1+l2-1;
n=-2:1:3 ;
x1=[x zeros(1,l3-l1)];
h1=[h zeros(1,l3-l2)];
y=[zeros(1,l3)];
for i=1:l3
for j=1:i
y(i)=y(i)+x1(j)*h1(i-j+1) ;
end
end
subplot(3,1,1)
stem(n1,x);
%xlim(l3) ;
xlabel('time');
ylabel('amplitude');
title('Signal 1');
grid on;
subplot(3,1,2)
stem(n2,h);
xlabel('time');
ylabel('amplitude');
title('Signal 2');
grid on;
subplot(3,1,3)
stem(n,y);
xlabel('time');
ylabel('amplitude');
title('Convulated Signal');
grid on;
7.
clc;
clear all;
close all ;
syms n w a ;
x=0.5^n;
y=ztrans(x);
pretty(y) ;
x=exp(1i*w*n);
y=ztrans(x);
pretty(y) ;
x=sin(w*n);
y=ztrans(x);
pretty(y) ;
x=a^n*(cos(w*n));
y=ztrans(x);
pretty(y) ;
8.
9.