You are on page 1of 118

Program no 1

WAP to generate a random noise of amplitude 0.5 Vpp, add it to a generated low frequency signal of 200 Hz and pass it through an LPF of 300 Hz and FS1 and compare the filtered o/p with the original signal to see if noise is reduced. clc clear close all %SPECIFICATION samp= 2000; fp= 300; fs=400; ap=.5; as=50; wp=ap/(samp/2); ws=as/(samp/2); [n,Wn]=buttord(wp,ws,ap,as);%ORDER & CUTOFF CALCULATION [b,a]=butter(n,Wn,'low');%COEFFICIENT CALCULATION [h,o]=freqz(b,a,256);%FREQUENCY RESPONSE plot(o/pi, 20*log10(abs(h)));%PLOT IMPULSE RESPONSE xlabel('n'); ylabel('dB'); title('impulse response'); %LOW FREQ SIGNAL GENERATE n=0:1/samp:1; x=cos(2*pi*200*n); %RANDOM SIGNAL GENERATE m=2001; d=rand(1,m)-.5; %I/P GENERATE p=x+d; y=filter(b,a,p); %PLOT THE I/P & O/P OF THE FILTER IN FREQ DOMAIN figure subplot 211,plot (abs(fft(p))); xlabel('freq(hz)'); ylabel('amplitude X(f)'); title('i/p in freq domain'); subplot 212,plot (abs(fft(y))); xlabel('freq(hz)'); ylabel('amplitude X(f)'); title('o/p in freq domain'); %PLOT THE I/P & O/P OF THE FILTER IN TIME DOMAIN figure subplot 211,plot (n,p); xlabel('time');

ylabel('amplitude x(t)'); title('i/p to filter in time domain'); subplot 212, plot (n,y); xlabel('time'); ylabel('amplitude x(t)'); title('filtered o/p in time domain');

Fig1: impulse response of LPF

Fig2: comparison of i/p & o/p in freq domain.

Fig3: comparison of i/p & o/p in time domain. Prithwiraj Sinha DE/11/EC/01

PROGRAM no 2
WAP to generate a sinusoidal signal consisting of %frequencies 300Hz,600Hz and 1200Hz with FS2 and pass it through any LTI %system H(z) and compare the time and frequency domain input and output. clc clear clear all %specification %FS2=5000Hz=samp %H(z)={num=[1,3,2];den=[1,-0.1,o.5]} samp=5000; n=0:1/samp:1; x=cos(2*pi*300*n)+cos(2*pi*600*n)+cos(2*pi*1200*n);%x=input num=[1 3 2]; den=[1 -0.1 0.5]; y=filter(num,den,x);%y=output figure subplot 211, plot(n(1:100),x(1:100)); title('input in Time Domain'); subplot 212, plot(n(1:100),y(1:100)); title('output in Time Domain'); figure subplot 211, plot(n,abs(fft(x))) title('input in Frequency Domain'); subplot 212, plot(n, abs(fft(y))) title('output in Frequency Domain');

Submitted by:Debajyoti Deb (DE/11/EC/002)

Q3. WAP to generate a sinusoidal signal consisting of frequencies 100Hz, 200Hz


and 1000Hz with FS1 and pass it through a system H(z) which is cascade combination of two LTI systems H1(z) and H2(z) with zero initial condition and prove the output is same even if u change the order of H1(z) and H2(z) in the cascade connection.
clc; clear; close all; samp=2000;%FS1 n=0:1/samp:1; %input signal x=cos(2*pi*100*n)+cos(2*pi*200*n)+cos(2*pi*1000*n); H1num=[2.24 2.49 2.24]; H1den=[1 -0.4 0.75]; ic=[0,0]; y1=filter(H1num,H1den,x,ic); H2num=[1,2,0.24]; H2den=[1,0.9,1]; y2=filter(H2num,H2den,y1,ic); figure subplot 121, plot(n,abs(fft(x))) %now changing the order of H1(z) and H2(z) in the cascade connection. y3=filter(H2num,H2den,x,ic); y4=filter(H1num,H1den,y3,ic); figure subplot 221, plot(n, abs(fft(y2))) subplot 222, plot(n, abs(fft(y4)))

Result

Done by Surya Vaydunth(DE/11/EC/03)

4.PROGRAM TO SHOW THAT H1(z) & H2(z) IN CASCADE IS LTI SYSTEM % H1(z)={num1=[2.24, 2.49, 2.24]; den1=[1, -0.4, 0.75 ]} % H2(z)={num2=[1, 2, 0.24]; den2=[1, -0.9, 1]} clear all; clc; close all n=0:40; a=2; b=-3;D=5; % a & b are arbitrary constants & D is delay x1=cos(2*pi*0.1*n); % x1 & x2 are inputs to H1(z) x2=cos(2*pi*0.4*n); x=a*x1+b*x2; % x is input to H1(z) such that x=a*x1+b*x2 ic=[0 0]; % initially relaxed % to check whether H1(z)& H2(z) in cascade is linear num1=[2.24, 2.49, 2.24]; den1=[1, -0.4, 0.75 ]; y1=filter(num1,den1,x1,ic);% output of H1(z) when x1 is input y2=filter(num1,den1,x2,ic);% output of H1(z) when x2 is input y=filter(num1,den1,x,ic);% output of H1(z) when x is input num2=[1, 2, 0.24]; den2=[1, -0.9, 1]; z1=filter(num2,den2,y1,ic);% output of H2(z) when y1 is input z2=filter(num2,den2,y2,ic);% output of H2(z) when y2 is input z=filter(num2,den2,y,ic);% output of H2(z) when y is input zt=a*z1+b*z2;% expected output for the system to be linear d=z-zt;% difference between actual o/p & expected o/p if abs(sum(sum(d)))<10^(-3) % H1(z)& H2(z) in cascade is linear since for x1:z1, x2:z2, % a*x1+b*x2:a*z1+b*z2 % to check whether H1(z) & H2(z) in cascade is time invariant xd=[zeros(1,D) x];% delayed signal x yd=filter(num1,den1,xd,ic);% output of H1(z) when xd is input zd=filter(num2,den2,yd,ic);% output of H2(z) when yd is input t=z-zd(1+D:41+D); if abs(sum(sum(t)))<10^(-3) disp('H1(z) and H2(z) in cascade is LTI system') else disp('H1(z) and H2(z) in cascade is not LTI system') end else disp('H1(z) and H2(z) in cascade is not LTI system') end

% to show the linearity of the cascaded system subplot(3,1,1), stem(n,z); grid subplot(3,1,2), stem(n,zt); grid subplot(3,1,3), stem(n,d); grid

% to show time invariance of the cascaded system figure subplot(3,1,1), stem(z); grid subplot(3,1,2), stem(zd); grid subplot(3,1,3), stem(t); grid OUTPUT- H1(z) and H2(z) in cascade is LTI system

original output 200 z 0 -200 0 5 10 15 20 25 n expected output 30 35 40

200 zt 0 -200 0 x 10
-13

10

15

20 n difference

25

30

35

40

1 d 0 -1

10

15

20 n

25

30

35

40

Graph1-To show linearity of the system

original output 200 zt 0 -200 0 5 10 15 20 25 30 35 40 45

delayed output 200 zd 0 -200 0 5 10 15 20 25 difference 1 0 -1 0 5 10 15 20 n 25 30 35 40 45 t 30 35 40 45 50

Graph2- To show time invariance of the system

NAME-SHREYASEE DEBNATH ROLL NO. DE/11/EC/004

Program no 5
WAP to check whether a given system H1(z) and H(z) in cascade is stable and time invariant. Program:clear all; clc; close all; %TIME INVARIANCE PROPERTY N=40; n=0:N; D=10; x=3*cos(2*pi*0.1*n)-2*cos(2*pi*0.4*n); xd=[zeros(1,D) x]; num1=[2.24 2.49 2.24]; den1=[1 -0.4 0.75]; num=[1 3 2]; den=[1 -0.1 0.5]; ic=[0 0];% initially relaxed %ic=[0 2];% initially not relaxed y1=filter(num1,den1,x,ic); y=filter(num,den,y1,ic); yd1=filter(num1,den1,xd,ic); yd=filter(num,den,yd1,ic); d=y-yd(1+D:41+D); subplot(3,1,1),stem(y),grid; title('original o/p'); subplot(3,1,2),stem(yd),grid; title('delayed o/p'); subplot(3,1,3),stem(d),grid; title ('diffrence between original and delayed o/p') if abs(sum(sum(d)))<10^(-3) disp('LTI SYSTEM IS TIME-SHIFT INVARIANT') else disp('LTI SYSTEM IS TIME-SHIFT VARIANT') end %STABILITY PROPERTY h1=impz(num1,den1,N+1); sum1=0; for k=1:N+1 sum1=sum1+h1(k); if abs(sum1)>10^6; p=0; else

p=1; end end h=impz(num,den,N+1); sum=0; n=0:N; for k=1:N+1 sum=sum+h(k); if abs(sum)>10^6; q=0; else q=1; end end if (p+q)==2 disp('LTI SYSTEM IS STABLE') else disp('LTI SYSTEM IS UNSTABLE') end figure stem(n,h),grid; title ('stability check'); disp('Total Sum of impulses ='), disp(sum)

Fig1: checking the time invariance property (original output, delayed output and the difference between the two).

Fig 2: showing the stability property of the system.

-ASHUTOSH (DE/11/EC/05)

Program no: 6
WAP to check whether a given system H1(z)and H2(z)in cascade is stable and follows the superposition theorem.

clear all; clc; close all; %stability property num1=[2.24 2.49 2.24]; den1=[1 -0.4 .75]; num=[1 3 2]; den=[1 -.1 .5]; N=40; n=0:N; h1=impz(num1,den1,N+1); sum1=0; for k=1:N+1 sum1=sum1+h1(k); if abs(sum1)>10^6 p=0; else p=1; end end h=impz(num,den,N+1); sum=0; for k=1:N+1 sum=sum+h(k); if abs(sum)>10^6; q=0; else q=1; end end if (p+q)==2; disp('LTI system is stable'); else disp('LTI system is unstable'); end figure stem(n,h); grid; title('stability check'); disp('total sum of impulse=');

disp(sum); %superposition check a=2; b=-3; x1=cos(2*pi*0.1*n); x2=cos(2*pi*0.4*n); x=a*x1+b*x2; ic=[0 0];% initially relaxed %ic=[0 2];% initially not relaxed %1st system y1=filter(num1,den1,x1,ic); y2=filter(num1,den1,x2,ic); y=filter(num1,den1,x,ic); yt=a*y1+b*y2; d=y-yt; if abs(sum(sum(d)))<10^(-3); m=0; disp('SYSTEM H1(Z) IS LINEAR') else m=1; disp('SYSTEM H1(Z) IS NON-LINEAR') end subplot 121, stem(n,abs(d)); %%%%%2nd system y11=filter(num,den,y1,ic); y22=filter(num,den,y2,ic); yf1=filter(num,den,yt); yf=a*y11+b*y22; d1=yt-yf; if abs(sum(sum(d1)))<10^(-3); no=0; disp('SYSTEM H2(Z) IS LINEAR') else no=1; disp('SYSTEM H2(Z) IS NON-LINEAR') end subplot 122, stem(n,abs(d1)); if m+no==2; disp('cascade doesnt follow superposition') end if m+no==1; disp('cascade doesnt follow superposition') else disp('cascade follow superposition') end

Fig 1: showing the stability property of the system.

Fig: 2 showing superposing property

RANDHEER KUMAR RAVI DE/11/EC/06

Program no 7
:- WAP to calculate the convolution output of x9n0=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3 using overlap-add method with

h(n)=[1 0 -1] without using the inbuilt commands and compare the result with the output of the conv command. Program:clc; clear all; close all; x=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3]; %input signal h=[1 0 -1]; %impulse response L=4; %length of each block %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% yy=conv(x,h); subplot 311, stem(yy) title('Using LONG linear filtering') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % overlap add method Nx=length(x); %length of input sequence is computed M=length(h); %length of impulse response sequence is computed M1=M-1; %overlapping points R=rem(Nx,L); % Remainder(R) is calculated by dividing length of input N=L+M1; %size of DFT is computed x=[x zeros(1,L-R)]; % L-R zeros are appended to input sequence h=[h zeros(1,N-M)]; % N-M zeros are appended to the impulse response sequence K=floor(Nx/L); y=zeros(K+1,N); % produces zero matrix z=zeros(1,M1); % produces zero matrix %dividing to K blocks for k=0:K xp=x(L*k+1:L*k+L); % points are overlapping xk=[xp z]; % zeroes are padded y(k+1,:)=cconv(xk,h,N); %circular convolution of input signal and response end yp=y'; %transpose of yp

[x,y]=size(yp); % determining the size of array for i=L+1:x; for j=1:y-1 temp1=i-L; temp2=j+1; temp3=yp(temp1,temp2)+yp(i,j); % used in the for loop yp(temp1,temp2)=temp3; end end z=1; % setting counter z=1 for j=1:y for i=1:x if ((i<=L & j<=y-1)|(j==y)) ypnew(z)=yp(i,j); %to store the values in one Dimensional array z=z+1; % incrementing the counter end end end y=ypnew; % storing the value of ypnew in y subplot 312, stem(y) title('Using Overlap Add method') d=yy-y(1:length(yy)); subplot 313, stem(d) title('Difference')

Using LONG linear filtering 10 0 -10

10

12

14

16

18

Using Overlap Add method 10 0 -10

0 x 10
-15

10

12

14

16

18

Difference

2 0 -2

10

12

14

16

18

Submitted by:Danish Khan DE/11/EC/007

PROGRAM:8
WAP to calculate the convolution output of x(n)=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3] %%using overlap-save method with h(n)=[1 0 -1] without using the inbuilt commands %%and compare the result with the output of the conv command. %circular convolution %function [c]=dcconv(a,b,N) %A=fft(a,N); %B=fft(b,N); %C=A.*B; %c=ifft(C,N); clc clear all close all %overlap save method of convolution x=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3];%input signal h=[-1 0 1];%inmpulse response N=3;%length of filter Nx=length(x);%length of i/p sequence is calculated M=length(h);%length of impulse response id calculated %calculated M1=M-1;%overlapping points L=N-M1;%number of points in each block is calculated x=[zeros(1,M-1), x, zeros(1,N-1)];%M-1 zeros are appended to i/p h=[h zeros(1,N-M)];%N-M zeros are appended to the impulse %response sequence K=floor((Nx+M1-1)/L);%decimal adjustment y=zeros(K+1,N);%produces zero matrix of the order 9X4 for k=0:K xk=x(k*L+1:k*L+N);%points are overlapping as in 1:2,2:3 Y(k+1,:)=dcconv(xk,h,N);%circular convolution of input signal & response end Y=Y(:,M:N);%the last column of matrix is stored in Y y=(Y(:))'%output through overlap save y2=conv(x,h)%using 'conv' command

OUTPUT:

y= Columns 1 through 11 -1.0000 -2.0000 -2.0000 -2.0000 -2.0000 1.0000 Columns 12 through 17 3.0000 y2 = Columns 1 through 19 0 0 -1 -2 -2 -2 4 6 2 -2 -4 -2 1 3 0 -5 -3 4 3 0 -5.0000 -3.0000 4.0000 3.0000 4.0000 6.0000 2.0000 -2.0000 -4.0000

Columns 20 through 21 0 0

Submitted by:Swagata das DE/11/EC/008

Program no 9
%WAP to calculate the convolution output of %x(n)=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3] using overlapsave method with h(n)=[ 1 -1] without using the inbuilt commands and compare the result with the output of the overlap-add output of the same. %(Designed by Dipyaman Modak (DE/11/EC/09)] %circular convolution %function [c]=dcconv(a,b,N) %A=fft(a,N); %B=fft(b,N); %C=A.*B; %c=ifft(C,N); clc clear all close all %overlap save method x=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3]; h=[-1 1]; N=2; Nx=length(x); sequence is computed M=length(h); response sequence is computed M1=M-1; L=N-M1; each block is computed x=[zeros(1,M-1), x, zeros(1,N-1)]; appended to input sequence h=[h zeros(1,N-M)]; appended to the impulse response sequence K=floor((Nx+M1-1)/L); y=zeros(K+1,N); matrix of the order 9X4. for k=0:K xk=x(k*L+1:k*L+N); overlapping as in 1:2,2:3 Y(k+1,:)=dcconv(xk,h,N); convolution of input signal & response end Y=Y(:,M:N); matrix is stored in Y

%input signal %impulse response %length of filter %legth of input %length of impulse %overlapping points %number of points in % M-1 zeros are % N-M zeros are %decimal adjustment. % produces zero %points are %circular %the last column of

yoverlap=(Y(:))' %transpose of y -------------------------------------------------------------------------------------------------------------------------------------------------------------------------x1=[1 2 3 4 -1 -2 -3 0 1 2 0 -1 0 4 3]; %input signal h1=[-1 1]; %impulse response L1=2; %length of filter Nx1=length(x1); %legth of input sequence is computed M1=length(h1); %length of impulse response sequence is computed M2=M1-1; %overlapping points N1=L1+M2; %size of DFT is computed R1=rem(Nx1,L1); % Remainder(R) is calculated by dividing length of input % sequence(Nx) by the length of response(L) x1=[x1 zeros(1,L1-R1)]; % L-R zeros are appended to input sequence h1=[h1 zeros(1,N1-M1)]; % N-M zeros are appended to the impulse response sequence K1=floor((Nx1)/L1); %decimal adjustment y1=zeros(K1+1,N1); %produces zero matrix z1=zeros(1,M2); %produces zero matrix for k1=0:K1 xp1=x1(L1*k1+1:L1*k1+L1); % points are overlapping xk1=[xp1 z1]; %zeroes are padded y1(k1+1,:)=dcconv(xk1,h1,N1); %circular convolution of input signal and response end yp1=y1'; %transpose of yp [x1,y1]=size(yp1); % determining the size of array for i=L1+1:x1; for j=1:y1-1 temp1=i-L1; %three variables are used to store temp2=j+1; %the result obtained temp3=yp1(temp1,temp2)+yp1(i,j);%in the for loop yp1(temp1,temp2)=temp3; end end

z=1; % setting counter z=1 for j=1:y1; for i=1:x1 if ((i<=L1 && j<=y1-1)||(j==y1)) ypnew(z)=yp1(i,j); %to store the values in one Dimensional array z=z+1; % incrementing the counter end end end yoverlapadd=ypnew % storing the value of ypnew in y %y convolution output

yoverlapsave = -1 2 -1 1 -1 -1 -1 -4 1 5 3 1 1 -3 -1 -1

yoverlapadd = Columns 1 through 11 -1.0000 -1.0000 -1.0000 -1.0000 5.0000 1.0000 1.0000 -3.0000 -1.0000 -1.0000 2.0000 Columns 12 through 17 1.0000 -1.0000 -4.0000 1.0000 3.0000 0

Submitted byDipyaman Modak. DE/11/ECE/09

Program no 11
%WAP

to design a LPF of same specifications being IIRB and IIRC-II %type and compare their outputs in time domain when a signal lying %in transition band is passed through them with Ap=0.5dB and As=50dB. Clc; Clear; Close all; fp=500; fs=600; samp=2000; ap=.5; as=50; wp=fp/(samp/2); ws=fs/(samp/2); [N,wn]=buttord(wp,ws,ap,as); [M,wm]=cheb2ord(wp,ws,ap,as); [b,a]=butter(N,wn); [H,W]=freqz(b,a,256); [c,d]=cheby2(M,as,wm); [I,X]=freqz(c,d,256); subplot 121,plot(W/(2*pi),20*log10(abs(H))) subplot 122,plot(X/(2*pi),20*log10(abs(I))) n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*700*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x); subplot 222, plot(n,abs(fft(y1))) y2=filter(c,d,x); subplot 223, plot(n,abs(fft(y2)))

FIGURE 1:

FIGURE 2:

SUBMITTED BY: Mahashweta dey ROLL NO.: DE/11/EC/11

Program no 12
%%WAP to design a BSF of same specifications being IIRC-I and IIRE type and %%compare their outputs in time domain when a signal lying in transition band %%is passed through them with Ap=0.5dB and As=60dB. fp1=300;%passband frequency fs1=400;%stopband frequency fs2=600;%stopband frequency fp2=700;%passband frequency samp=2000;%sampling frequency ap=.5;%passband ripples as=60;%stopband ripples wp=[fp1 fp2]/(samp/2);%cutoff frequency ws=[fs1 fs2]/(samp/2); %chebyshev-I [N,wn]=cheb1ord(wp,ws,ap,as); % determining order and natural frequency [b,a]=cheby1(N,ap,wn,'stop'); [H,W]=freqz(b,a,256); subplot 121,plot(W/(2*pi),20*log10(abs(H)))%%plots the frequency response curve %ellipord [M,wm]=ellipord(wp,ws,ap,as); % determining order and natural frequency [c,d]=ellip(M,ap, as,wm,'stop'); [I,X]=freqz(c,d,256); subplot 122,plot(X/(2*pi),20*log10(abs(I)))%plots the frequency response curve n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*800*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x); y2=filter(c,d,x); subplot 222, plot(n,abs(fft(y1))) subplot 223, plot(n,abs(fft(y2)))

Submitted byShruti Roychoudhary DE/11/EC/12

Problem number 13

%13.WAP to design a HPF of same specifications being IIR-CI and IIRC-II type %and compare their outputs in time domain when a signal lying in transition %band is passed through them with Ap=0.7dB and As=50dB. %Solution: clc;close all;clear all; %specification: samp=2000;%sampling frequency Fp=400; %passband frequency Fs=300; %stopband frequency Ap=0.7; %pass band attenuation As=50; %stop band attenuation Wp=Fp/(samp/2); %passband edge frequency(normalized) Ws=Fs/(samp/2); %stopband edge frequency(normalized) %Design of chebyshevI filter [N1,Wn1]=cheb1ord(Wp,Ws,Ap,As); %order and natural frequency calculation [b1,a1]=cheby1(N1,Ap,Wn1,'high'); %coefficient calculation [H1,W1]=freqz(b1,a1,256); %frequency response calculation subplot 211, plot(W1/2*pi,20*log10(abs(H1)));xlabel('phase angle');ylabel('gain in dB');title('frequency response Oof IIR CI'); title('frequency response of chebyshevI filter'); %Design of chebyshevII filter [N2,Wn2]=cheb1ord(Wp,Ws,Ap,As); [b2,a2]=cheby1(N2,Ap,Wn2,'high'); [H2,W2]=freqz(b2,a2,256); subplot 212, plot(W2/2*pi,20*log10(abs(H2)));xlabel('phase angle');ylabel('gain in dB');title('frequency response of IIR CII'); title('frequency response of chebyshevII filter'); %check for output from each of the filter for the same input lying in the transition band; n=0:1/samp:1; X=cos(2*pi*n*350)+cos(2*pi*n*380);%Input signal Y=filter(b1,a1,X);%output from IIR chebychevI Z=filter(b2,a2,X);%output from IIR chebychevII figure subplot 311,plot(n(1:500),X(1:500));xlabel('discrete time');ylabel('X');title('input in time domain'); subplot 312,plot(n(1:500),Y(1:500));xlabel('discrete time');ylabel('Y');title('output in time domain of IIR C I'); subplot 313,plot(n(1:500),Z(1:500));xlabel('discrete time');ylabel('Z');title('output in time domain of IIR C II'); %comparison of the outputs of two filters figure plot(n(1:500),Y(1:500),n(1:500),Z(1:500));%time domain comparision of outputs of IIR CI and IIR CII xlabel('discrete time');ylabel('Y and Z');title('time domain comparision of outputs of IIR CI and IIR CII');

fre u n re o seo ch b e I filte q e cy sp n f e ysh v r 0 gain in dB -1 0 0 -2 0 0 -3 0 0 -4 0 0

0 .5

2 .5 3 pa ag h se n le fre u n re o seo ch b e II filte q e cy sp n f e ysh v r

1 .5

3 .5

4 .5

0 gain in dB -1 0 0 -2 0 0 -3 0 0 -4 0 0

0 .5

1 .5

2 .5 pa ag h se n le

3 .5

4 .5

input in time domain 2 X 0 -2 0 0.05 0.1 0.15 discrete time output in time domain of IIR C I 0.2 0.25

1 Y 0 -1 0 0.05 0.1 0.15 discrete time output in time domain of IIR C II 0.2 0.25

1 Z 0 -1 0 0.05 0.1 0.15 discrete time 0.2 0.25

time domain comparision of outputs of IIR CI and IIR CII 0.6

0.4

0.2

Y and Z

-0.2

-0.4

-0.6

-0.8

0.05

0.1 0.15 discrete time

0.2

0.25

Submitted by: Manish Sharma (DE/11/EC/13)

PROGRAM NO 14
.WAP to design a BPF of same specifications being IIRB and IIRCII type %and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap and As.

clc;close all;clear all; %specification: samp=2000;%sampling frequency %band-edges: fp1=400; fs1=300; fp2=700; fs2=800; ap=0.5;%pass band attenuation as=80;%stop band attenuation wp=[fp1 fp2]/(samp/2); ws=[fs1 fs2]/(samp/2); %iir butterworth design: [N1,wn1]=buttord(wp,ws,ap,as);%order and cutoff calculation [b1,a1]=butter(N1,wn1,'bandpass');%coefficient calculation [H1,W1]=freqz(b1,a1,256);%frequency responce %iir chebyshev2 design: [N2,wn2]=cheb2ord(wp,ws,ap,as);%order and cutoff calculation [b2,a2]=cheby2(N2,as,wn2,'bandpass');%coefficient calculation [H2,W2]=freqz(b2,a2,256);%frequency responce figure subplot 211, plot(W1/2*pi,20*log10(abs(H1)));xlabel('phase angle');ylabel('gain in dB');title('frequency response Oof IIR B'); subplot 212, plot(W2/2*pi,20*log10(abs(H2)));xlabel('phase angle');ylabel('gain in dB');title('frequency response of IIR CII'); %testing: n=0:1/samp:0.1; x=cos(2*pi*350*n)+cos(2*pi*750*n); y1=filter(b1,a1,x); y2=filter(b2,a2,x); figure subplot 311,plot(n,x);xlabel('discrete time');ylabel('x');title('input in time domain'); subplot 312,plot(n,y1);xlabel('discrete time');ylabel('y1');title('output in time domain of IIR B'); subplot 313,plot(n,y2);xlabel('discrete time');ylabel('y2');title('output in time domain of IIR CII'); figure

plot(n,y1,n,y2);%time domain comparision of outputs of IIR B and IIR CII xlabel('discrete time');ylabel('y1 and y2');title('time domain comparision of outputs of IIR B and IIR CII');

Submitted by:RAKESH YADAV DE/11/EC/14

PROGRAM NO 15
:WAP to design a BPF of same specifications being hamming FIR-W and IIRE type and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap=0.7dB and As=50dB.

Solution: samp=2000; n=0:1/samp:1; L=66; %Filter length fp1=400; %passband frequency fp2=600; %stopband freq fn=samp/2; % Nyquist frequency, fs1=sampling frequency wp1=fp1/fn; wp2=fp2/fn; Wp=[wp1 wp2]; % Normalized cut off frequencies, W1=.4,W2=.6 w=window(@hamming,L+1); %hamming window subplot 131, plot(1:L+1,w); b = fir1(L, Wp, 'bandpass',w); [H,X]=freqz(b,1,256); subplot 132, plot(X/pi, 20*log10(abs(H))); % elliptical ,BPF of pass 400-600Hz fs1=300; fs2=700; ap=.7; as=50; Ws=[fs1 fs2]/(samp/2); [N,wn]=ellipord(Wp,Ws,ap,as); [c,d]=ellip(N,ap,as,wn,'bandpass'); [I,X]=freqz(c,d,256); subplot 133,plot(X/(2*pi),20*log10(abs(I))) x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*800*n); figure y1=filter(b,1,x); subplot 221, plot(n,abs(fft(x))) subplot 222, plot(abs(fft(y1))) y2=filter(c,d,x); subplot 223, plot(n,abs(fft(y2)))

Subplot 131:Graph represent Hamming Windows

Subplot 132:Impulse response of


hamming FIR-W

Subplot 133:Impulse response of IIRE bandpass

SUBPLOT 131: Graph representation of fft(x)

SUBPLOT 132: Graph representation of fft(y1)

SUBPLOT 133: Graph representation of fft(y2)

Sunil Kumar (DE/11/EC/15)

Program no 16
WAP to design a BSF of same specifications being FIRPM and Kaiser FIR-W type and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap=0.6dB and As=40dB.

clc clear close all samp=2000; n=0:1/samp:1; x=cos(2*pi*350*n)+cos(2*pi*600*n); ap=0.6;%ap=-20*log10(1-dp) as=40;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [n,fo,mo,w] = firpmord( [300 400 550 650], [1 0 1], [dp ds dp], samp ); b = firpm(n,fo,mo,w); [h,o]=freqz(b,1,256); figure plot(o/pi, 20*log10(abs(h))); title 'FIRM' y=filter(b,1,x); [N1,W1,bta,filtype] = kaiserord( [300 400 550 650], [1 0 1], [dp ds dp], samp ); w1 = window(@kaiser,N1+1,bta); figure subplot 121, plot(1:N1+1,w1); b1 = fir1(N1, W1, filtype, kaiser(N1+1,bta), 'noscale'); [H,O]=freqz(b1,1,256);

subplot 122, plot(O/pi, 20*log10(abs(H))); y1=filter(b1,1,x); title 'kaiser window' figure subplot 311, plot(abs(fft(x))); title 'input signal' subplot 312, plot(abs(fft(y))); title 'FIRPM output' subplot 313, plot(abs(fft(y1))); title 'kaiser output'

Dayananda Rajkumar Roll no. DE/11/EC/16

Program no 17
WAP to design a LPF of same specifications being FIRPM and hanning FIR-W type and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap=0.8dB and As=80dB.

samp=2000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n); ap=0.8;%ap=-20*log10(1-dp) as=80;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); % FIRPM [n,fo,mo,w] = firpmord( [300 400], [1 0], [dp ds], samp ); b = firpm(n,fo,mo,w); [H,W]=freqz(b,1,256); .................... % hanning FIR-W L=66; I=.3; w=window(@hanning,L+1);%Hanning window figure subplot 131, plot(1:L+1,w); c = fir1(L, I, 'low',w); [h,X]=freqz(c,1,256); figure subplot 132, plot(W/pi, 20*log10(abs(H))); subplot 133, plot(X/pi, 20*log10(abs(h))); figure subplot 221, plot(abs(fft(x))); y1=filter(b,1,x); y2=filter(c,1,x); subplot 222, plot(abs(fft(y1))); subplot 223, plot(abs(fft(y2)));

Figure 1

Figure 2

S BABINA DEVI DE/11/EC/17

Program no 18

WAP to design a HPF of same specifications being FIRPM and Gaussian FIRW type and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap=0.5dB and As=50dB. samp=2000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n); ap=0.5;%ap=-20*log10(1-dp) as=50;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); % FIRPM [n,fo,mo,w] = firpmord( [300 400], [0 1], [ds dp], samp ); b = firpm(n,fo,mo,w); [H,W]=freqz(b,1,256); .................... % guassian window, FIR-W L=66; I=.4; w=window(@gausswin,L+1);%gaussian window figure subplot 131, plot(1:L+1,w); c = fir1(L, I, 'high',w); [h,X]=freqz(c,1,256); figure subplot 132, plot(W/pi, 20*log10(abs(H))); subplot 133, plot(X/pi, 20*log10(abs(h))); figure subplot 221, plot(abs(fft(x))); y1=filter(b,1,x); y2=filter(c,1,x); subplot 222, plot(abs(fft(y1))); subplot 223, plot(abs(fft(y2)));

Figure 1

Figure 2

Figure 3

Submitted by:T.Esther Lotha DE/11/EC/018

Program no 19

WAP to design an IIRE BPF with an IIRE LPF and a HPF and compare %the result with a direct IIRE BPF with Ap=0.5dB and As=50dB. Clc; Clear; Close all; fp1=500; fs1=600; samp=2000; ap=.5; as=50; wp=fp1/(samp/2); ws=fs1/(samp/2); [N,wn]=ellipord(wp,ws,ap,as); [b,a]=ellip(N,ap, as,wn); [H,W]=freqz(b,a,256); %plot(W/(2*pi),20*log10(abs(H))) fs2=500; fp2=600; wp=fp2/(samp/2); ws=fs2/(samp/2); [b1,a1]=ellip(N,ap,as,wn,'high'); [I,X]=freqz(b1,a1,256); %subplot 111,plot(X/(2*pi),20*log10(abs(I))) n=0:1/samp:1; x=cos(2*pi*550*n)+cos(2*pi*600*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x); %subplot 222, plot(n,abs(fft(y1))) y2=filter(b1,a1,y1); subplot 222, plot(n,abs(fft(y2))) FIGURE

SUBMITTED BY : Songhita misra ROLL NO.:DE/11/EC/019

Program no 20
WAP to design an FIR BPF with passbands 300 to 700Hz and 900 to 1400Hz with FS1 with Ap=0.5dB and As=80dB.

samp=5000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n); ap=0.5;%ap=-20*log10(1-dp) as=80;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [N,W,bta,filtype] = kaiserord( [250 300 700 750 850 900 1400 1450 ], [0 1 0 1 0], [ds dp ds dp ds], samp ); w = window(@kaiser,N+1,bta); figure subplot 121, plot(1:N+1,w); b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale'); [h,o]=freqz(b,1,256); subplot 122, plot(o/pi, 20*log10(abs(h))); y=filter(b,1,x); figure subplot 211, plot(abs(fft(x))); subplot 212, plot(abs(fft(y)));

Figure 1

Figure 2

Benjungkum la DE/11/EC/20

Program no 21
%WAP to design an FIR BSF with stopbands 100 to 400Hz, 800 to % 1000Hz and 1200 to 1400 with FS2 , Ap=0.5dB and As=50dB. Clc; Clear; Close all; samp=3000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n); ap=0.5;%ap=-20*log10(1-dp) as=50;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [N,W,bta,filtype] = kaiserord( [50 100 400 450 750 800 1000 1050 1150 1200 1400 1450], [1 0 1 0 1 0 1], [dp ds dp ds dp ds dp], samp ); w = window(@kaiser,N+1,bta); figure subplot 121, plot(1:N+1,w); b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale'); [h,o]=freqz(b,1,256); subplot 122, plot(o/pi, 20*log10(abs(h))); y=filter(b,1,x); figure subplot 211, plot(abs(fft(x))); subplot 212, plot(abs(fft(y)));

FIGURE 1:

FIGURE 2:

SUB MITTED BY: PRERNA ROLL NO.: DE/11/EC/021

Program no 22
To WAP to compare the variation of output for a signal in transition band of an Kaiser FIR-W as its order is increased by 10 when its input signal is lying in the transition band. clc clear close all % specificationssamp=2000; ap=0.5;%ap=-20*log10(1-dp) as=50;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); % Kaiser FIR-W design:% Order and cut off calculation for low pass filter [N,W,bta,filtype] = kaiserord( [300 400], [1 0], [dp ds], samp ); % creating kaiser window k1 = window(@kaiser,N+1,bta); % coefficient(b)calculation b1= fir1(N, W, filtype, kaiser(N+1,bta), 'noscale'); % creating filter 1 of order N [h1,o1]=freqz(b1,1,256); % creating filter 2 whose order is increaced by 10 k2 = window(@kaiser,N+11,bta); b2 = fir1(N+10, W, filtype, kaiser(N+11,bta), 'noscale'); [h2,o2]=freqz(b2,1,256); n=0:1/samp:1; % testing:% input signalx=cos(2*pi*100*n)+cos(2*pi*350*n)+cos(2*pi*700*n); % output sisnal of filter 1 of order N y1=filter(b1,1,x); % output sisnal of filter 2 whose order is increaced by 10 y2=filter(b2,1,x); % figure for frequense response of input, output of filter 1 and filter 2 respectively figure subplot 311, plot(abs(fft(x))); title('figure for frequense response of input'); subplot 312, plot(abs(fft(y1))); title('figure for frequense response of output of filter 1 ');

subplot 313, plot(abs(fft(y2))); title('figure for frequense response of output of filter 2'); % figure for kaiser window for filter 1 and 2 figure subplot 121, plot(1:N+1,k1); title('figure for kaiser window of filter 1 '); subplot 122, plot(1:N+11,k2); title('figure for kaiser window of filter 2 ');

Submitted by :- Sandeep Banerjee (Roll No : DE/11/EC/22)

Program no 23
. WAP to compare the variation of output for a signal in pass band of

an IIR-CII as its order is increased by 3 when its input signal is lying in the transition band. %LPF of cut off 500Hz fp=500; fs=600; samp=2000; ap=.5; as=40; wp=fp/(samp/2); ws=fs/(samp/2); [N,wn]=cheb2ord(wp,ws,ap,as); [b,a]=cheby2(N,as,wn); [H,W]=freqz(b,a,256); figure subplot 121 ,plot(W/(2*pi),20*log10(abs(H))) M=N+3; %increase d order by 3 [b1,a1]=cheby2(M,as,wn); [I,X]=freqz(b1,a1,256); subplot 122 ,plot(X/(2*pi),20*log10(abs(I))) n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*700*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x);

subplot 222, plot(n,abs(fft(y1))) y2=filter(b1,a1,y1) subplot 223, plot(n,abs(fft(y2)))


L. Bijendra Singh (Roll no. DE/11/EC/23)

Program no 24
WAP to compare the variation of output for a signal in stop band of an IIR-CI as its order is increased by 3 when its input signal is lying in the transition band. %BSF of stop band 400-600Hz %specificationsfp1=300; fs1=400; fs2=600; fp2=700; samp=2000; ap=.5; as=40; wp=[fp1 fp2]/(samp/2); ws=[fs1 fs2]/(samp/2); %order and cut off calculation for band stop filter [N,wn]=cheb1ord(wp,ws,ap,as); %coefficient calculation [b,a]=cheby1(N,ap,wn,'stop'); %creating filter 1 of order N [H,W]=freqz(b,a,256); figure subplot 121,plot(W/(2*pi),20*log10(abs(H))) title('figure for frequense response of filter 1'); % creating filter 2 whose order is increaced by 3 M=N+3; [b1,a1]=cheby1(M,ap,wn,'stop'); [I,X]=freqz(b1,a1,256); subplot 122, plot(X/(2*pi),20*log10(abs(I))) title('figure for frequense response of filter 2'); n=0:1/samp:1; %input signal x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*800*n); figure subplot 311, plot(abs(fft(x))) title('figure for frequense response of input'); y1=filter(b,a,x); y2=filter(b1,a1,x); subplot 312, plot(abs(fft(y1))) title('figure for frequense response of output of filter 1'); subplot 313, plot(abs(fft(y2))) title('figure for frequense response of output of filter 2');

submitted by Prasenjit Das

(Roll no -DE/11/EC/24)

Program no 25
WAP to compare the variation of output for a signal in transition % band of an Kaiser FIR-W as its order is increased by 10 when its %input signal is lying in the transition band. Clc; Clear; Close all; samp=2000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*350*n)+cos(2*pi*700*n); %signal with frequency components 100hz,350hz,700hz. ap=0.5; %ap=-20*log10(1-dp) as=80; %as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); % KAISER FIR-W% [N,W,bta,filtype] = kaiserord( [300 400], [1 0], [dp ds], samp ); w = window(@kaiser,N+1,bta); figure subplot 121, plot(1:N+1,w); % response of the kaiser window b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale'); [H,o1]=freqz(b,1,256); subplot 122, plot(o1/pi, 20*log10(abs(H))); %Kaiser Frequency response y1=filter(b,1,x); % fir kaiser %increasing the order by 10 M=N+10; w1 = window(@kaiser,M+1,bta); figure subplot 231, plot(1:M+1,w1); % response of the kaiser window b1 = fir1(M, W, filtype, kaiser(M+1,bta), 'noscale'); %Kaiser Frequency response [I,o2]=freqz(b1,1,256); subplot 232, plot(o2/pi, 20*log10(abs(I))); subplot 233, plot(n,abs(fft(x))); subplot 234, plot(n,abs(fft(y1)));

y2=filter(b1,1,x); subplot 235, plot(n,abs(fft(y2)));


FIGURE 1:

FIGURE 2:

SU BMITTED BY:AHNA SHARAN

DE/11/EC/25

program No: - 27
%WAP to compare the variation of output for a signal in stop band of a Hamming FIR-W as its order is increased by 10 when its input signal is lying in the transition band. %Program:%using Hamming window clc clear all close all samp=2000; %sampling frequency n=0:1/samp:1; %number of samples

x=cos(2*pi*360*n)+cos(2*pi*620*n); %input frequency signal in the transition band N1=66; %filter order W1=[.4 .6]; %normalized cut off frequency w1=window(@Hamming,N1+1); %Hamming window figure %figure No:-1 subplot 121, plot(1:N1+1,w1); plot for the window xlabel('samples') ; %labelling of x axis ylabel('Amplitude') ; %labelling of y axis title 'Hamming window plot of order N' title of the plot b1 = fir1(N1, W1, 'stop',w1); THE DEFAULT WINDOW=Hamming [h,o]=freqz(b1,1,256); %computation of frequency response subplot 122, plot(o/pi, 20*log10(abs(h))),grid on; %plot of frequency response (magnitude(dB) VS Normalised frequency) xlabel(' Normalised Frequency (Hz)') ; %labelling of x axis ylabel('Amplitude') ; %labelling of y axis title 'Frequency response of order N'; %title of the plot y1=filter(b1,1,x); filtered output of the given signal through a filter of order N N2=N1+10; now, order of the filter is increased by 10 W2=[.4 .6]; %normalised cut off frequency w2=window(@Hamming,N2+1); %Hamming window figure %figure No:-2 subplot 121, plot(1:N2+1,w2); %plot for the windows xlabel('samples') ; %labelling of x axis

% %

% %

ylabel('Amplitude') ; %labelling of y axis title 'Hamming window plot of order N+10' %title of the plot b2 = fir1(N2, W2, 'stop',w2); %THE DEFAULT WINDOW=Hamming [H,O]=freqz(b2,1,256); %computation of frequency response subplot 122, plot(O/pi, 20*log10(abs(H))), grid on; %plot of frequency response (magnitude(dB) VS Normalised frequency) xlabel('Normalised Frequency (Hz)') ; %labelling of x axis ylabel('magnitude(dB') ; %labelling of y axis title 'Frequency response of order N+10'; %title of the plot y2=filter(b2,1,x); %filtered output of the given signal through a filter of order N+10 figure %figure No:-3 subplot 311, plot(abs(fft(x))); %plot of the input signal(amplitude VS frequency) xlabel('Frequency (Hz)') ; %labelling of x axis ylabel('Amplitude') ; %labelling of y axis title 'input signal'; %title of the plot subplot 312, plot(abs(fft(y1))); %plot of the output signal(amplitude VS frequency) through a filter of order N xlabel('Frequency (Hz)') ; %labelling of x axis ylabel('Amplitude') ; %labelling of y axis title 'Hamming order N output'; %title of the plot subplot 313, plot(abs(fft(y2))); %plot of the output signal(amplitude VS frequency) through a filter of order N+10 xlabel('Frequency (Hz)') ; %labelling of x axis ylabel('Amplitude') ; %labelling of y axis

title 'Hamming order N+10 output' %title of the plot

FIGURE: FIGURE 1:Hm in w d w lo o od rN a m g ino p t f r e 1 1 0 Feu nyr s os o od rN r qec e pne f r e

0 .9

0 .8 -0 1 0 .7 -0 2 0 .6 Am plitude 1 0 2 0 3 0 s mle aps 4 0 5 0 6 0 7 0 Am plitude -0 3

0 .5

-0 4

0 .4 -0 5 0 .3 -0 6

0 .2

0 .1

-0 7

0 0

-0 8

0 .1

0 .2

0 .3

0 .4 0 .5 0 .6 Nr a e Fe un y( z omlis d r qe c H)

07 .

0 .8

0 .9

FIGURE2:Hmin wdw looo eN1 a mg ino p t f r r +0 d 1 1 0 F qec r s os oo eN1 r uny epne f r r +0 e d

0 . 9

0 . 8 -0 1 0 . 7 -0 2 0 . 6 Am litu e p d m g itu e B a n d (d 1 0 2 0 3 0 4 0 sm s ap le 5 0 6 0 7 0 8 0

-0 3

0 . 5

-0 4

0 . 4 -0 5 0 . 3 -0 6 0 . 2

0 . 1

-0 7

0 0

-0 8

0 .1

0 .2

0 . 3

0 .4 0 .5 Nr a e F qec ( z o lis d r uny H m e )

0 . 6

0 . 7

0 .8

0 .9

FIGURE3:-

inp sig l ut na 10 00 Amplitude

5 00

5 00

10 0 0 F qu cy (H re en z) H m g o er Nou ut am in rd tp

15 00

2 0 00

25 0 0

10 00 Amplitude

5 00

5 00

10 0 0 F qu cy (H re en z) H m go e N 0o am in rd r +1 utpu t

15 00

2 0 00

25 0 0

10 00 Amplitude

5 00

5 00

10 0 0 F qu cy (H re en z)

15 00

2 0 00

25 0 0

Program description 1. Determine the sample frequency and the signal whose frequency lies in the transition band. 2. 3. 4. Design the hamming window FIR filter of the given order (N) and of given normalized frequency. Now, pass the given input signal into the filter and plot the output. Design another hamming window FIR filter of order N+10 and of same normalized frequency.

5. Now, again pass the same input signal into the second filter and plot the output.
Submitted by : Rahul Roushan DE/11/EC/27

Program no 29
WAP to design a BPF of IIR-CI and IIR-CII of same specifications and keep their order same (i.e take order N= max[NIIR-CI, NIIR-CII])and compare their outputs in the pass band with FS1. Solution: - %BPF of pass band 400-600Hz

clc; %clears the command window% clear;%Clear variables and functions from memory% close all;% closes all the open figure windows%

fs1=300; fp1=400; fp2=600; fs2=700; samp=2000; 2000hz (FS1)% ap=.5; the passband% as=80; stop band% wp=[fp1 fp2]/(samp/2); normalized from ws=[fs1 fs2]/(samp/2); normalized from

% % % % %

1st stopband edge frequency 1st passband edge frequency 2nd passband edge frequency 2nd stopband edge frequency sampling frequency of

% 0.5dB of attenuation in % 80dB of attenuation in the % pass band edge frequencies, % 0 to 1 % % stop band edge frequencies,

% 0 to 1 % [N1,wn]=cheb1ord(wp,ws,ap,as); %{N1=minimum order with the provided % specifications of IIR-CI, wn= Chebyshev1 natural frequency}% [N2,wm]=cheb2ord(wp,ws,ap,as); %{N2=minimum order with the provided %specifications of IIR-CII, wm= Chebyshev2 natural frequency}% N=max(N1,N2); %{calculates the maximum order among N1 & N2 % and returns N}% [b,a]=cheby1(N,ap,wn,'bandpass'); %{filter coefficients for IIR-CI %in length N+1,vectors b(numerator) and a(denominator)}% [c,d]=cheby2(N,as,wm,'bandpass'); %{filter coefficients for IIR-CII %in length N+1,vectors c(numerator)and d(denominator)}% [H,W]=freqz(b,a,256); % {H=256 point complex frequency response vector % and W= 256 point frequency vector} % [I,X]=freqz(c,d,256); % {I=256 point complex frequency response vector % and X= 256 point frequency vector} % figure subplot 121,plot(W/(2*pi),20*log10(abs(H)),'b')

% Frequency respnose plot of IIR-CI% xlabel('W/(2*pi)'); ylabel('H'); title('Frequency respnose of IIR-CI'); subplot 122,plot(X/(2*pi),20*log10(abs(I)),'r') % Frequency respnose plot of IIR-CII% xlabel('X/(2*pi)'); ylabel('I'); title('Frequency respnose of IIR-CII'); n=0:1/samp:1; %generation of points for time domain plot% x=cos(2*pi*400*n)+cos(2*pi*550*n)+cos(2*pi*630*n); %Input signal that is to be tested% figure subplot 221, plot(n,abs(fft(x))) %time domain plot of input signal % xlabel('n'); ylabel('x'); title('input signal'); y1=filter(b,a,x); %signal x passes through the IIRCI filter% subplot 222, plot(n,abs(fft(y1)),'r') %time domain plot of IIR-CI output signal % xlabel('n'); ylabel('y1'); title('output signal of IIR-CI');
y2=filter(c,d,x); %signal x passes through the IIR-CII filter% subplot 223, plot(n,abs(fft(y2)),'b') %time domain plot of IIR-CII output signal % xlabel('n'); ylabel('y2'); title('output signal of IIR-CII'); subplot 224, plot(n,abs(fft(y1)),'r',n,abs(fft(y2)),'b') % combine plot for comparision% xlabel('n'); ylabel('y1,y2'); title('combine plot -red=IIR-CI, blue=IIR-CII');

RESULT: Figure 1.

Figure 2.

Submitted by: Baddrud Zaman Laskar

DE/10/EC/101

Program no 30
WAP to design a LPF of IIR-B and IIR-E of same specifications and keep their order same (i.e take order N= max[NIIR-B NIIR-E)and compare their outputs in the passband edge, cutoff and stopband edge with FS1. Solution:%LPF of cut off 500Hz clc; clear; close all; fp=500; % passband edge frequency fs=600; % stopband edge frequency samp=2000; % sampling frequency of 2000hz (FS1)% ap=.5; % 0.5dB of attenuation in the passband% as=50; % 50dB of attenuation in the stop band% wp=fp/(samp/2);% pass band edge frequencies, normalized from % 0 to 1 % ws=fs/(samp/2);% stop band edge frequencies, normalized from % 0 to 1 %

[N1,wn]=buttord(wp,ws,ap,as); %{N1=minimum order provided with the specifications of IIRB, % wn= Butterworth natural frequency}% [N2,wm]=ellipord(wp,ws,ap,as); %{N2=minimum order with the provided %specifications of IIR-E, wm= Elliptic natural frequency}% N=max(N1,N2);%{calculates the maximum order among N1 & N2 % and returns N}% [b,a]=butter(N,wn); %{filter coefficients for IIR-B %in length N+1,vectors b(numerator) and a(denominator)}% [H,W]=freqz(b,a,256); % {H=256 point complex frequency response vector % and W= 256 point frequency vector} % [c,d]=ellip(N,ap,as,wm); %{filter coefficients for IIR-E %in length N+1,vectors c(numerator)and d(denominator)}% [I,X]=freqz(c,d,256); % {I=256 point complex frequency response vector % and X= 256 point frequency vector} % subplot 121,plot(W/(2*pi),20*log10(abs(H))) % Frequency respnose plot of IIR-B% xlabel('W/(2*pi)'); ylabel('H'); title('Frequency respnose of IIR-B'); subplot 122,plot(X/(2*pi),20*log10(abs(I))) % Frequency respnose plot of IIR-E% xlabel('X/(2*pi)'); ylabel('I'); title('Frequency respnose of IIR-E'); n=0:1/samp:1; %generation of points for time domain plot% x=cos(2*pi*480*n)+cos(2*pi*500*n)+cos(2*pi*530*n); %Input signal that is to be tested% figure subplot 221, plot(n,abs(fft(x))) %time domain plot of input signal % xlabel('n'); ylabel('x');

title('input signal'); y1=filter(b,a,x);%signal x passes through the IIR-B filter% subplot 222, plot(n,abs(fft(y1))) %time domain plot of IIR-B output signal % xlabel('n'); ylabel('y1'); title('output signal of IIR-B'); y2=filter(c,d,x);%signal x passes through the IIR-E filter% subplot 223, plot(n,abs(fft(y2))) %time domain plot of IIR-E output signal % xlabel('n'); ylabel('y2'); title('output signal of IIR-E');

Result:

Su bmitted by Sa harul Alom Barlaskar Ro ll no: DE/10/EC/102

Program no 31
WAP to design a LPF of IIR-B and IIR-CII of same specifications and keep their order same (i.e take order N= max[NIIR-CII, NIIR-B])and compare their outputs in the passband edge, cutoff and stopband edge with FS1. PROGRAM:

%LPF of cut off 500Hz clc;

clear; close all; fp=500;% passband frequency fs=600;% stopband frequency samp=2000;% sampling frequency (fs1) ap=.5;% passband ripple as=50;% stopband ripple wp=fp/(samp/2); ws=fs/(samp/2); [N1,wn]=buttord(wp,ws,ap,as); [N2,wm]=cheb2ord(wp,ws,ap,as); N=max(N1,N2); [b,a]=butter(N,wn); [H,W]=freqz(b,a,256); [c,d]=cheby2(N,as,wm); [I,X]=freqz(c,d,256); subplot 121,plot(W/(2*pi),20*log10(abs(H))) subplot 122,plot(X/(2*pi),20*log10(abs(I))) n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*700*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x); subplot 222, plot(n,abs(fft(y1))) y2=filter(c,d,x); subplot 223, plot(n,abs(fft(y2)))

FIGURE1:

FIGURE2

SUBMITTED BY

KIRAN BORAH DE/10/EC/103

Program no 32
%BSF of stop 400-600Hz fp1=300; fs1=400; fs2=600; fp2=700; samp=10000; ap=.5; as=50; wp=[fp1 fp2]/(samp/2); ws=[fs1 fs2]/(samp/2); [N1,wn]=cheb1ord(wp,ws,ap,as); [N2,wm]=ellipord(wp,ws,ap,as);

N=max(N1,N2); [b,a]=cheby1(N,ap,wn,'stop'); [H,W]=freqz(b,a,256); [c,d]=ellip(N,ap,as,wm,'stop'); [I,X]=freqz(c,d,256); figure subplot 121,plot(W/(2*pi),20*log10(abs(H))) subplot 122,plot(X/(2*pi),20*log10(abs(I))) n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*800*n); figure subplot 221, plot(n,abs(fft(x))) y1=filter(b,a,x); y2=filter(c,d,x); subplot 222, plot(n,abs(fft(y1))) subplot 223, plot(n,abs(fft(y2)))

submitted by, S AURAV KUMAR DE/10/EC/104

Program no 33
WAP to design a BSF of FIR-PM and Kaiser FIR-W of same specifications and keep their order same (i.e take order N= max[NFIR-W, NFIR-PM])and compare their outputs in the passband edge, cutoff and stopband edge with FS2 clc; clear; close all;

samp=5000; n=0:1/samp:1; x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n); ap=0.6;%ap=-20*log10(1-dp) as=40;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [N1,fo,mo,w] = firpmord( [300 400 550 650], [1 0 1], [dp ds dp], samp ); [N2,Y,bta,filtype] = kaiserord( [300 400 550 650 ], [1 0 1], [dp ds dp], samp ); N=max(N1,N2); b = firpm(N,fo,mo,w); [H,W]=freqz(b,1,256); w = window(@kaiser,N+1,bta); subplot 111, plot(1:N+1,w); % response of the kaiser window c = fir1(N, Y, filtype, kaiser(N+1,bta), 'noscale'); [I,X]=freqz(c,1,256); figure subplot 211, plot(W/pi, 20*log10(abs(H))); %PM Frequency response subplot 212, plot(X/pi, 20*log10(abs(I))); %Kaiser Frequency response figure subplot 311, plot(abs (fft(x))); y1=filter(b,1,x); % firpm subplot 312, plot(abs(fft(y1))); y2=filter(c,1,x); % fir kaiser subplot 313, plot(abs(fft(y2)));

Fig: Frequency response of Kaiser window

Fig: Filter output of FIRPM and Kaiser

output of filter

Fig: Input signal, FIRPM filter output and kaiser

Sa muel MS Dawngliana DE/10/EC/105

Program no 34
WAP to design a HPF of FIR-PM and Kaiser FIR-W of same specifications and keep their order same (i.e take order N= max[NFIR-W, NFIR-PM])and compare their outputs in the passband edge, cutoff and stopband edge with FS2. clc; clear; close all; samp=5000;%sampling frequency FS2=5KHz n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*1100*n) +cos(2*pi*1500*n);%input signal ap=.5;%passband attenuation 0.5 dB as=80;%stopband attenuation 80 dB fs=900;%stopband edge frequency 900 Hz fp=1000;%passband edge frequency 1000 Hz dp=1-10^(-ap/20);%ap=-20*log10(1-dp) ds=10^(-as/20);%as=-20*log10(ds) [N1,fo,mo,w1]=firpmord([300 400],[0 1],[ds dp],samp); %approximate order, % normalized frequency band edges, frequency band amplitudes,and weights in %FIRPM [N2,W,bta,filtype]=kaiserord([300 400],[0 1],[ds dp],samp); %approximate %order N2, normalized frequency band edges Wn,and weights in kaiser FIR window N=max(N1,N2);%select same order b1=firpm(N,fo,mo,w1); [h1,o1]=freqz(b1,1,256); figure w2=window(@kaiser,N+1,bta); subplot 111,plot(1:N+1,w2);%response of kaiser window b2=fir1(N,W,filtype,kaiser(N+1,bta),'noscale'); [h2,o2]=freqz(b2,1,256); figure subplot 211,plot(o1/pi,20*log10(abs(h1)));%FIRPM Frequency response subplot 212,plot(o2/pi,20*log10(abs(h2)));%Kaiser Frequency response figure subplot 311,plot(abs(fft(x))); y1=filter(b1,1,x);%FIRPM subplot 312,plot(abs(fft(y1))); y2=filter(b2,1,x);%FIR Kaiser

subplot 313,plot(abs(fft(y2)));

Fig: Frequency response of Kaiser window

Fig: Filter output of FIRPM and Kaiser

Fig: Frequency domain output of the filter

Submitted by: Bikash Roy

DE/10/EC/106

Program no 35
WAP to design a HPF of Hamming FIR-W and Kaiser FIR-W of same specifications and keep their order same and compare their outputs in the passband edge,cutoff and stopband edge with FS3. clc; clear; close all; samp=10000; n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*450*n)+cos(2*pi*900*n); fs=700; fp=800; ap=.5; as=80; dp=1-10^(-ap/20);%ap=-20*log10(1-dp) ds=10^(-as/20);%as=-20*log10(ds) N1=66; W1=.4; [N2,W,bta,filtype]=kaiserord([300 400],[0 1],[ds dp],samp); N=max(N1,N2); w=window(@hamming,N+1); % response of the kaiser window subplot 111,plot(1:N+1,w); b1=fir1(N,W1,'high',w); [h1,o1]=freqz(b1,1,256); w1=window(@kaiser,N+1,bta); figure subplot 111,plot(1:N+1,w1); b2=fir1(N,W,filtype,kaiser(N+1,bta),'noscale'); figure [h2,o2]=freqz(b2,1,256); subplot 211,plot(o1/pi,20*log10(abs(h1))); subplot 212,plot(o2/pi,20*log10(abs(h2))); figure subplot 311,plot(n,abs(fft(x))); y1=filter(b1,1,x); subplot 312,plot(n,abs(fft(y1))); y2=filter(b2,1,x);

subplot 313,plot(n,abs(fft(y2)));

Fig:Frequency response of the hamming window

Fig:Frequency response of the kaiser window

Fig: Filter output of hamming and Kaiser

Fig: Frequency domain output of the filter

Submitted by:Abhinoy Ray

DE/10/EC/108

Program no 36
WAP to design a LPF of Gaussian FIR-W and Kaiser FIR-W of same specifications and keep their order same and compare their outputs in the passband edge, cutoff and stopband edge with FS3. clc; clear; close all; samp=10000;%sampling frequency FS3=10KHz n=0:1/samp:1; x=cos(2*pi*300*n)+cos(2*pi*400*n)+cos(2*pi*600*n); fp=800;%passband edge frequency 800 Hz fs=900;%stopband edge frequency 900 Hz ap=.5; as=80; dp=1-10^(-ap/20); ds=10^(-as/20); N1=66; W1=.4; [N2,W2,bta,filtype]=kaiserord([300 400],[1 0],[dp ds],samp); N=max(N1,N2); w=window(@gausswin,N+1); subplot 111,plot(1:N+1,w);%response of gausswin window b1=fir1(N,W1,'low',w); [h1,o1]=freqz(b1,1,256); w1=window(@kaiser,N+1,bta);%response of kaiser window figure subplot 111,plot(1:N+1,w1); b2=fir1(N,W2,filtype,kaiser(N+1,bta),'noscale'); figure [h2,o2]=freqz(b2,1,256); subplot 211,plot(o1/pi,20*log10(abs(h1))); subplot 212,plot(o2/pi,20*log10(abs(h2))); figure subplot 311,plot(abs(fft(x))); y1=filter(b1,1,x); subplot 312,plot(abs(fft(y1))); y2=filter(b2,1,x); subplot 313,plot(abs(fft(y2)));

Fig: Frequency response of gausswin window

Fig: Frequency response of kaiser window

Fig: Filter output of gausswin and Kaiser

Fig: Frequency domain output of the filter

Bikash Khandal DE/10/EC/109

Program no 37
WAP to design a BPF of Blackman Harries FIR-W and Kaiser FIR-W ofsamespecifications and keep& %their order same and compare their outputs in the passband edge, cutoff and stopband edge with FS2. samp=5000; %sampling frequency n=0:1/samp:1; % samples x=cos(2*pi*750*n)+cos(2*pi*800*n)+cos(2*pi*1050*n) +cos(2*pi*1070*n); %input signal% fs1=700; %stop frequency fp1=800; %passband frequency fs2=1000;%stop ferquency fp2=1100; %passband frequency ap=.5;%passband attenuation as=80; %stopband attenuation dp=1-10^(-ap/20);% passband deviation ds=10^(-as/20);%stopband deviaion [N2,W2,bta,filtype] = kaiserord( [ 700 800 1000 1100 ], [0 1 0], [ds dp ds], samp );%kaiserord passband filter w2 = window(@kaiser,N2+1,bta);%kaiser window figure subplot 121, plot(1:N2+1,w2); b2 = fir1(N2, W2, filtype, kaiser(N2+1,bta), 'noscale'); [H,O]=freqz(b2,1,256); subplot 122, plot(O/pi, 20*log10(abs(H))); y2=filter(b2,1,x); N1=N2; W1=[.32 .4];%normalised frequency w1=window(@blackmanharris,N1+1);%Blackman Harris Window figure subplot 121,plot(1:N1+1,w1); b1=fir1(N1,W1,'bandpass',w1); [h,o]=freqz(b1,1,256); y1=filter(b1,1,x); subplot 122, plot(o/pi, 20*log10(abs(h))); figure subplot 311, plot(abs(fft(x))); subplot 312, plot(abs(fft(y1))); subplot 313, plot(abs(fft(y2)));

FIGURE:1
1 0.9 0.8 -20 0.7 0.6 0.5 0.4 0.3 -100 0.2 0.1 0 -120 -140 -40 -60 -80 20 0

100

200

300

0.5

FIGURE:2

1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0

0 -20 -40 -60 -80 -100 -120 -140 -160 -180 -200

100

200

300

0.5

FIGURE:3
3000 2000 1000 0 1500 1000 500 0 3000 2000 1000 0 0 1000 2000 3000 4000 5000 6000 0 1000 2000 3000 4000 5000 6000 0 1000 2000 3000 4000 5000 6000

-Submitted by; Manish Singh DE/10/EC/110.

Program no: 38
WAP to design a BPF of same specification being chebyshaw FIR-W and compare their outputs in time domain when a signal lying in transition band is passed through them with ap=.5 and as=80dB with FS2. clc; close all; clear; %bandpass filter of band 400-500; samp=2000; n=0:1/samp:1; x=cos(2*pi*200*n)+cos(2*pi*500*n)+cos(2*pi*700*n); %bpf for chebwin; N=66;%{N=minimum order provided with the specifications of chebwin W=[.4,.6];%cutt off frequency w=window(@chebwin,N+1);%calling chebwin window; figure subplot 121,plot(1:N+1,w); b=fir1(N,W,'bandpass',w); [H,O]=freqz(b,1,256); %BPF forIIR-CII type; ap=.5 ;% 0.5dB of attenuation in the passband% as=80; % 80dB of attenuation in the stopband% fs1=300; %stop band edge1 frequency fp1=400;%passband edge1 frequency fp2=500; %passband edge2 frequency fs2=600; %stop band edge2 frequency wp=[fp1 fp2]/(samp/2);% band stop edge frequencies, normalized from 0 to 1 ws=[fs1 fs2]/(samp/2);% pass band edge frequencies, normalized from 0 to 1 [h1,wn]=cheb2ord(wp,ws,ap,as); [b1,a]=cheby2(h1,as,wn,'bandpass'); [H1,O1]=freqz(b,a,256); figure subplot 121,plot(O/pi,20*log10(abs(H)))%Frequency respnose plot of chewinFIR-w window subplot 122,plot(O1/2*pi,20*log10(abs(H1)))%Frequency respnose plot of IIR -chebyshev2 figure subplot 231,plot(abs(fft(x)))%time domain plot of input signal y1=filter(b,1,x); y2=filter(b1,a,x);

subplot 232,plot(abs(fft(y1)))%time domain plot of output signal of chebwin FIR-w subplot 233,plot(n,abs(fft(y2)))%time domain plot of output signal of IIR-CII

RESULT:

Fig: 1 chebwin window figure

Fig:2 response of the chebwin FIR-W and IIR-CII filter type respectively

Fig3: Input and output of chebwin FIR-W and IIR-CII type

window

RANDHEER KUMAR RAVI DE/11/EC/06

Prg 39. WAP to design a HPF of same specifications being Cebyshev FIR-W and IIR-CI type and compare their outputs in time domain when a signal lying in transition band is passed through them with Ap=0.5dB and As=80dB with FS2. Solution:

%HPF of cut off 600hz samp=5000; n=0:1/samp:1; x=cos(2*pi*700*n)+cos(2*pi*550*n); fp=600;%passband edge frequency fs=500;%stopband edge frequency wp=fp/(samp/2);% pass band edge frequencies, normalized from 0 to 1 % ws=fs/(samp/2);% stop band edge frequencies, normalized from 0 to 1 % ap=0.5;% 0.5dB of attenuation in the passband% as=80;% 80dB of attenuation in the stopband% N=66;%{N=minimum order provided with the specifications of chebyshev FIRW, W=.24; %cutt off frequency% w=window(@chebwin,N+1); % calling chebyshev window% subplot 121, plot(1:N+1,w); b=fir1(N,W,'high',w); % coefficient for Chebywin% [H,O]=freqz(b,1,256);% {H=256 point complex frequency response vector % and O= 256 point frequency vector} % subplot 122, plot(O/pi,20*log10(abs(H)))% Frequency respnose plot of chebyshev FIRW% y=filter(b,1,x); %filtered output% figure subplot 221, plot(abs(fft(x)))%time domain plot of input signal % subplot 222,plot(abs(fft(y)))%time domain plot of output signal % [N1,wn]=cheb1ord(wp,ws,ap,as);%{N1=minimum order provided with the specifications of IIR-CI, % wn= natural frequency}% [b1,a1]=cheby1(N1,ap,wn,'high'); %in length N+1,vectors b1(numerator) and a1(denominator)}% [I,X]=freqz(b1,a1,256); % frequency respnose Vector% figure subplot 111, plot(X/(2*pi),20*log10(abs(I))) % frequency response plot%

n=0:1/samp:1; figure subplot 211, plot(n,abs(fft(x))) y2=filter(b1,a1,x); subplot 212, plot(n,abs(fft(y2))) RESULT:
1 0.9 0.8 0.7 -40 0.6 -60 0.5 -80 0.4 0.3 0.2 0.1 0 -100 -120 -140 -160 20 0 -20

20

40

60

80

0.5

Figure(1); Window response, frequency response of Chebyshev FIR-W

2500 2000 1500 1000 500 0 0 2000 4000 6000

2500 2000 1500 1000 500 0 0 2000 4000 6000

Fig(2); input signal, output signal


0

-50

-100

-150

-200

-250

-300

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0.5

Fig(3): frequency response of IIR-CI

4 0 0 0 2 0 0 0 0 . 10 . 20 . 30 . 40 . 50 . 60 . 7 0 . 80 . 9 1 4 0 0 0 2 0 0 0 0 0 0 . 10 . 20 . 30 . 40 . 50 . 60 . 7 0 . 80 . 9 1
Submitted by Baddrud Zaman laskar(DE/10/EC/101)

Fig(4): input signal, output signal

%Question 40.WAP to design a IIR-B LPF reduce the minimum order by 2 and check its linearity property. fp=500; %pass band frequency fs=600; %stop band frequency samp=2000; %sampling frequency n=0:1/samp:1; c=2; d=-1; %coefficients for linearity check %input signals x1=cos(2*pi*500*n); x2=cos(2*pi*700*n); x=c*x1+d*x2; ic=[0,0];%initially relaxed ap=.5;%passband attenuation as=40;%stopband attenuation %edge frequency bands wp=fp/(samp/2); ws=fs/(samp/2); %Design of filter [N,wn]=buttord(wp,ws,ap,as); M=N-2;%decresing the order [b,a]=butter(M,wn); [H,W]=freqz(b,a,256); y1=filter(b,a,x1);%output of x1 y2=filter(b,a,x2);%output of x2 figure subplot 111,plot(W/(2*pi),20*log10(abs(H))); figure subplot 221,plot(abs(fft(x1)));title('frequency domain plot of input signal x1'); subplot 222, plot(abs(fft(x2)));title('frequency domain plot of input signal x2'); subplot 223,plot(abs(fft(y1)));title('frequency domain plot of output of x1(y1)'); subplot 224, plot(abs(fft(y2)));title('frequency domain plot of output of x1(y2)'); y=filter(b,a,x);%output of x %linearity checking yt=c*y1+d*y2; dif=y-yt; if abs(sum(sum(dif)))<10^(-3) disp('FILTER IS LINEAR') else disp('FILTER IS NON-LINEAR') end figure subplot(3,1,1), stem(n(1:100),y(1:100)); grid;title('time domain plot for output of y');xlabel('discrete time(n)');ylabel('magnitude of y'); subplot(3,1,2), stem(n(1:100),yt(1:100)); grid;title('time domain plot for output of yt');xlabel('discrete time(n)');ylabel('magnitude of yt'); subplot(3,1,3), stem(n(1:100),dif(1:100)); grid;title('time domain plot for output of dif');xlabel('discrete time(n)');ylabel('magnitude of dif'); Output: FILTER IS LINEAR

f e u n yd minp t o in u s n l x r q e c o a lo f p t ig a 1 10 00

fr q e c d minp t o in u s n l x e u n y o a lo f p t ig a 2 10 00

50 0

50 0

0 0

10 00

20 00

30 00

0 0

10 00

20 00

30 00

f e u n yd minp t o o tp t o x ( 1 r q e c o a lo f u u f 1y ) 10 00

fr q e c d minp t o o tp t o x ( 2 e u n y o a lo f u u f 1y ) 1

50 0

0 .5

0 0

10 00

20 00

30 00

0 0

10 00

20 00

30 00

5 0 0 -0 5 -0 10 -5 10 -0 20 -5 20 -0 30 -5 30

05 .0

0 .1

05 .1

0 .2

05 .2

0 .3

05 .3

0 .4

05 .4

0 .5

time domain plot for output of y magnitude of y 2 0 -2 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 discrete time(n) time domain plot for output of yt 0.04 0.045 0.05

magnitude of yt

2 0 -2 0 x 10 0.005
-14

0.01

0.015

magnitude of dif

0.02 0.025 0.03 0.035 discrete time(n) time domain plot for output of dif

0.04

0.045

0.05

2 0

-2 0

0.005

0.01

0.015

0.02 0.025 0.03 discrete time(n)

0.035

0.04

0.045

0.05

Submitted by: Manish


Sharma(DE/11/EC/13)

%Q41.WAP to design a IIR-CI LPF reduce the minimum order by 2 and check its stability property. fp=500; %pass band frequency fs=600; %stop band frequency samp=2000; %sampling frequency ic=[0,0];%initially relaxed ap=.5;%passband attenuation as=40;%stopband attenuation wp=fp/(samp/2); ws=fs/(samp/2); %Design of filter [N,wn]=cheb1ord(wp,ws,ap,as); % decresing the order by 2 M=N-2; [b2,a2]=cheby1(M,wn,ap); [I,X]=freqz(b2,a2,256); figure subplot 111,plot(I/(2*pi),20*log10(abs(X))); %check for the stability Np=200;%number of samples h=impz(b2,a2,Np+1);%impulse response sum=0; ne=0:Np; for k=1:Np+1 sum=sum+h(k); if abs(sum)>10^6; disp('UNSTABLE LTI SYSTEM'); break end if abs(h(k))<10^(-6); disp('STABLE LTI SYSTEM'); break end if k==N+1; disp('STABLE LTI SYSTEM'); end end figure stem(ne,h); grid;title('time domain plot of immpulse responses'); disp('Total Sum of impulses ='), disp(sum)

Output: STABLE LTI SYSTEM


Total Sum of impulses = 0.9441

1 0 5 0 -5 -1 0 -1 5 -2 0 -2 5 -3 0 -3 5 -4 0 -0 .2

-0 5 .1

-0 .1

-0 5 .0

0 5 .0

0 .1

0 5 .1

0 .2

tim d m inp t o im p ls re p n e e o a lo f m u e s o s s 0 .5 0 .4 0 .3 0 .2 0 .1 0 -0 .1 -0 .2 -0 .3

2 0

4 0

6 0

8 0

10 0

10 2

10 4

10 6

10 8

20 0

Submitted by: Danish Khan


(DE/11/EC/07)

Program no 42 WAP to design a IIR-E LPF reduce the minimum order by 2 and check its time %invariance property. %LPF of cut off 500Hz clc clear clear all %Specification fp=500; fs=600; samp=2000; ap=.5; as=40; wp=fp/(samp/2); ws=fs/(samp/2); %Order &natural freq. [N,wn]=ellipord(wp,ws,ap,as); %Co-efficient calc. [b,a]=ellip(N,ap,as,wn); %Frequency Response [H,W]=freqz(b,a,256); subplot 111, plot(W/(2*pi),20*log10(abs(H))) title('frequency response'); n=0:1/samp:1; M=N-2;%reducing order by 2 %Co-efficient of New designed Filter [b1,a1]=ellip(M,ap,as,wn); %Frequency Response of New designed Filter [I,X]=freqz(b1,a1,256); figure %delay=d=10 ne=0:40;D=10; %Testing x=3*cos(2*pi*0.1*ne)-2*cos(2*pi*0.4*ne); xd=[zeros(1,D) x];%delayed input of x %ic=[0 0];(initial condition is zero) y=filter(b1,a1,x); yd=filter(b1,a1,xd);%delayed output of y d=y-yd(1+D:41+D);%difference of the outputs subplot(3,1,1),stem(y),grid; title('Output of Input Without Delay'); subplot(3,1,2),stem(yd),grid; title('output with delay'); subplot(3,1,3),stem(d),grid;

title('output of the difference between both outputs');

Submitted by:Debajyoti Deb (DE/11/EC/002)

Program no 43
WAP to design a FIR-PM LPF reduce the minimum order by 5 & check linearity. clc; clear; close all; samp=2000; n=0:1/samp:1; c=2; d=-3; x1=cos(2*pi*400*n); x2=cos(2*pi*600*n); x=c*x1+d*x2; ic=[0,0];%relaxed initial condition %..........design FIR-PM LPF.............. %specification ap=0.5;%ap=-20*log10(1-dp) as=80;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [N,fo,mo,w] = firpmord( [500 600], [1 0], [dp ds], samp ); M=N-5;%order reduced by 5 b=firpm(M,fo,mo,w);%coefficient calculation [h,o]=freqz(b,1,256);%freq response y3=filter(b,1,x1); y4=filter(b,1,x2); yt=c*y3+d*y4; y5=filter(b,1,x); dif=y5-yt; %plot the o/ps subplot(3,1,1), plot(n,y5); subplot(3,1,2),plot(n,yt); subplot(3,1,3), plot(n,dif); if abs(sum(sum(d)))<10^(-3) disp('LTI SYSTEM IS LINEAR') else disp('LTI SYSTEM IS NON-LINEAR') end Result LTI system is non-linear

Fig: linearity check. Done by :- Ansh (DE/11/EC/10)

Program no 44
WAP to design a Kaiser FIR-W LPF reduce the minimum order by 5 & check linearity. clc; clear; close all; samp=2000; n=0:1/samp:1; c=2; d=-3; x1=cos(2*pi*200*n);% first i/p x2=cos(2*pi*350*n);% second i/p x=c*x1+d*x2; ic=[0,0];% relaxed initial condition %................kaiser LPF-W designing............. %specification ap=0.5;%ap=-20*log10(1-dp) as=80;%as=-20*log10(ds) dp=1-10^(-ap/20); ds=10^(-as/20); [N,W,bta,filtype] = kaiserord( [300 400], [1 0], [dp ds], samp ); M=N-5; %decreasing d order by 5 w = window(@kaiser,M+1,bta);% generation of the window figure subplot 211, plot(1:M+1,w);%plot the window b = fir1(M, W, filtype, kaiser(M+1,bta), 'noscale'); %coefficient calculation [h,o]=freqz(b,1,256);%freq response calculation subplot 212, plot(o/pi, 20*log10(abs(h)));%plot the impulse response y=filter(b,1,x1); y1=filter(b,1,x2); figure subplot 221,plot(n,y);%...plot the o/ps... subplot 222, plot(n,y1);%...plot the o/ps... ...... y3=filter(b,1,x); yt=c*y+d*y1; ...... dif=y3-yt; %display whether the system is linear or non-linear if abs(sum(sum(dif)))<10^(-3) disp('LTI SYSTEM IS LINEAR') else

disp('LTI SYSTEM IS NON-LINEAR') end subplot 223, plot(n,y3);%...plot the o/ps... subplot 224, plot(n,yt);%...plot the o/ps... figure plot(n,dif);

Result LTI SYSTEM IS LINEAR

Done by :- Ansh (DE/11/EC/10)

You might also like