Ex 1 clear variables; Fp = [4000 6000]; %banda de trecere Fs = [3000 8000]; %banda de oprire Rp = 1; Rs = 40; Fes = 20*10^3; Wp = 2*pi*Fp; Ws = 2*pi*Fs; %domeniul analogic [n, Wn] = buttord(Wp,Ws,Rp,Rs,'s'); [b, a] = butter(n,Wn,'s'); %rasp la frecventa [Ha, wa] = freqs(b,a,2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impulse(b,a); %raps la impuls figure, pzmap(b,a); %diagrma poli zerouri if roots(a) <0 %stabilitate disp('FTB analogic stabil'); else disp('FTB analogic instabil'); end %domeniul digital [num, den] = impinvar(b,a,Fes); %rasp la impuls [Hz, wz] = freqz(num, den, 2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Hz)); subplot(2,1,2); plot(wa/pi, angle(Hz)); figure, impz(num, den); figure, zplane(num, den); if abs(roots(den)) <1 %stabilitate disp('FTB digital stabil'); else disp('digital instabil'); end Ex 2 clear variables; Fp = [4000 6000]; %banda de trecere Fs = [3000 8000]; %banda de oprire Rp = 1; Rs = 40; Fes = 20*10^3; Wp = 2*pi*Fp; Ws = 2*pi*Fs; %domeniul analogic [n, Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s'); [b, a] = cheby1(n,Rp,Wn,'s'); %rasp la frecventa [Ha, wa] = freqs(b,a,2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impulse(b,a); %raps la impuls figure, pzmap(b,a); %diagrma poli zerouri if roots(a) <0 %stabilitate disp('FTB analogic stabil'); else disp('FTB analogic instabil'); end %domeniul digital [num, den] = impinvar(b,a,Fes); %rasp la impuls [Hz, wz] = freqz(num, den, 2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Hz)); subplot(2,1,2); plot(wa/pi, angle(Hz)); figure, impz(num, den); figure, zplane(num, den); if abs(roots(den)) <1 %stabilitate disp('FTB digital stabil'); else disp('digital instabil'); end Ex3 clear variables; Fp = [4000 6000]; Fs = [3000 8000]; Rp = 1; Rs = 40; Fes = 20*10^3; Wp = 2*pi*Rp; Ws = 2*pi*Rs; %domeniul analogic [n, Wn] = buttord(Wp,Ws,Rp,Rs,'s'); [b, a] = butter(n, Wn, 's'); [Ha, wa] = freqs(b,a,2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impulse(b,a); figure, pzmap(b,a); if roots(a) < 0 disp('Stabil'); else displ('Instabil'); end %domeniul digital [num, den] = impinvar(b,a,Fes); [Hz, wz] = freqz(num, den, 2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impz(num, den); figure, zplane(num, den); if abs(roots(den)) < 1 disp('Stabil'); else displ('Instabil'); end Ex4 clear variables; Fp = [4000 6000]; Fs = [3000 8000]; Rp = 1; Rs = 40; Fes = 20*10^3; Wp = 2*pi*Rp; Ws = 2*pi*Rs; %domeniul analogic [n, Wn] = ellipord(Wp,Ws,Rp,Rs,'s'); [b, a] = ellip(n,Rp,Rs, Wp, 's'); [Ha, wa] = freqs(b,a,2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impulse(b,a); figure, pzmap(b,a); if roots(a) < 0 disp('Stabil'); else displ('Instabil'); end %domeniul digital [num, den] = impinvar(b,a,Fes); [Hz, wz] = freqz(num, den, 2^10); figure, subplot(2,1,1); plot(wa/pi, abs(Ha)); subplot(2,1,2); plot(wa/pi, angle(Ha)); figure, impz(num, den); figure, zplane(num, den); if abs(roots(den)) < 1 disp('Stabil'); else disp('Instabil'); end Ex5 clear variables; b = 2*[1 0 2]; a = conv([1 2],[2 3 2]); figure, freqs(b,a,2^10); if roots(a) < 0 disp('FTJ analogic stabil'); else disp('FTJ analogic instabil'); end Fes = 1/0.8; [bz, az] = bilinear(b, a, Fes); figure, freqz(bz,az) %FTj figure, zplane(bz, az); %FTJ digital stabil Ex6 clear variables; N=5; fc=0.2; [b,a]=butter(N,2*pi*fc/pi); figure, freqz(b,a) Ex7 dp = 0.1; ds = 0.01; fp = 0.22; fs = 0.25; Rp = 20*log10((1+dp)/(1-dp)); Rs = -20*log10(ds); Wp = 2*pi*Rp; Ws = 2*pi*Rs; [N,w]=buttord(Wp,Ws,Rp,Rs,'s'); [b,a]=butter(N,w,'s'); figure, freqz(b,a); figure, grpdelay(b,a) %%filtru digital filt, filtru analogic tf H=filt(b,a); %stabilitate if isstable(b,a)==1 disp('Filtru digital este stabil') else disp('Filtru digital este instabil') end Ex8 dp = 0.1; ds = 0.01; fp = 0.22; fs = 0.25; Rp = 20*log10((1+dp)/(1-dp)); Rs = -20*log10(ds); Wp = 2*pi*Rp; Ws = 2*pi*Rs; [n,w]=cheb1ord(Wp,Ws,Rp,Rs,'s'); [b,a]=cheby1(n,Rp,Wp,'s'); figure, freqz(b,a); figure, grpdelay(b,a) %%filtru digital filt, filtru analogic tf H=filt(b,a) %stabilitate if isstable(b,a)==1 disp('Filtru digital este stabil') else disp('Filtru digital este instabil') end Ex9 clear variables; n=0:199; fr=0.22; N=10; SBw=0.1; TBw=0.02; fs=[fr-SBw/2 fr+SBw/2]; fp=[fs(1)-TBw fs(2)+TBw]; Rs=40; Rp=3; x1=cos(2*pi*0.05*n); x2=cos(2*pi*0.22*n); %Chebyshev I [b1,a1]=cheby1(N/2,Rp,2*fp,'stop'); figure, freqz(b1,a1) y11=filter(b1,a1,x1); y12=filter(b1,a1,x2); figure, subplot, stem(n(100:160), x1(100:160)), hold all stem(n(100:160), y11(100:160),'--'),hold off; grid, xlim([99 159]) subplot, stem(n(100:160), x2(100:160)), hold all stem(n(100:160), y12(100:160),'--'),hold off; grid, xlim([99 159]) legend('input,output'), legend boxoff %Chebyshev II [b2,a2]=cheby2(N/2,Rs,2*fp,'stop'); figure, freqz(b2,a2) y11=filter(b2,a2,x1); y12=filter(b2,a2,x2); figure, subplot, stem(n(100:160), x1(100:160)), hold all stem(n(100:160), y11(100:160),'--'),hold off; grid, xlim([99 159]) subplot, stem(n(100:160), x2(100:160)), hold all stem(n(100:160), y12(100:160),'--'),hold off; grid, xlim([99 159]) legend('input,output'), legend boxoff