TUTORIAL – 7 BY :- VAISHNAV SHANKAR BATCH B2 ROLL NO – 37 REG NO : 150906260 1] CODE : clear; clc; fs=8000; wp=1000*2/fs; ws=1500*2/fs; rp=0.5; rs=30; [n1,wn1]=buttord(wp,ws,rp,rs); [n2,wn2]=cheb1ord(wp,ws,rp,rs); [n3,wn3]=cheb2ord(wp,ws,rp,rs); [n4,wn4]=ellipord(wp,ws,rp,rs); [b1,a1]=butter(n1,wn1); [b2,a2]=cheby1(n2,rp,wn2); [b3,a3]=cheby2(n3,rs,wn3); [b4,a4]=ellip(n4,rp,rs,wn4); [h1,on1]=freqz(b1,a1); [h2,on2]=freqz(b2,a2); [h3,on3]=freqz(b3,a3); [h4,on4]=freqz(b4,a4); subplot(221) plot(on1/pi,20*log10(abs(h1)));
title('BUTTERWORTH'); subplot(222) plot(on2/pi,20*log10(abs(h2))); title('CHEBYSHEV 1'); subplot(223) plot(on3/pi,20*log10(abs(h3))); title('CHEBYSHEV 2'); subplot(224) plot(on4/pi,20*log10(abs(h4))); title('ELLIPTIC')
OUTPUT :
2]
CODE : clear; clc; f=[0 0.25 0.375 1]; m=[1 1 0 0]; [k,a]=yulewalk(8,f,m); [h,w]=freqz(k,a,128); plot(w/pi,abs(h))
OUTPUT :
3]
CODE : clear; clc; f=[0 0.25 0.375 1]; m=[1 1 0 0]; [k,a]=yulewalk(8,f,m); [h1,w1]=freqz(k,a,128); [k,a]=firls(8,f,m); [h2,w2]=freqz(k,a,128); plot(w1/pi,abs(h1),w2/pi,abs(h2))
OUTPUT :
4]
CODE : clc; clear; wp=12*2/48; ws=8*2/48; rp=0.5; rs=60; [n,wn]=cheb1ord(wp,ws,rp,rs); [b,a]=cheby1(n,rp,wn); [h,w]=freqz(b,a); plot(w/pi,abs(h));
OUTPUT :
5]
CODE : clear; clc; fs=100; t=(1:100)/fs; wp1=10/50; wp2=20/50; ws1=5/50; ws2=25/50; s=sin(2*pi*5*t)+sin(2*pi*15*t)+sin(2*pi*30*t);
plot(t,s);grid; title('Time Domain Waveform(5,15,30Hz)'); wp=[wp1,wp2]; ws=[ws1,ws2]; rp=0.1; rs=40; [n,wn]=ellipord(wp,ws,rp,rs); [b,a]=ellip(n,rp,rs,wn); freqz(b,a); [H,w]=freqz(b,a); plot(w*fs/(2*pi),abs(H)); grid; sf=filter(b,a,s); figure(1);plot(t,sf);grid; S=fft(s,512);SF=fft(sf,512); f=[(0:255)/256*(fs/2)]; figure(2) plot(f, abs([S(1:256)', SF(1:256)'])); grid
OUTPUT :
6]
CODE : clear; clc; w=pi/24; n=0:49; y1=cos(2*w*n); y2=sin(2*w*n); figure(1) stem(n,y1); figure(2); stem(n,y2);
OUTPUT :
7]
Output