0% found this document useful (0 votes)
29 views2 pages

Basic Matlab Codes IIR

The document contains code for analyzing and designing filters. It calculates filter coefficients using the Butterworth and Chebyshev algorithms. It analyzes filters by obtaining their transfer functions, pole-zero maps, frequency responses, and plotting the results. Filter design parameters like cutoff frequencies and approximation errors are specified. The filters are also converted to other forms and their impulse and step responses analyzed.

Uploaded by

Oral Robertz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Basic Matlab Codes IIR

The document contains code for analyzing and designing filters. It calculates filter coefficients using the Butterworth and Chebyshev algorithms. It analyzes filters by obtaining their transfer functions, pole-zero maps, frequency responses, and plotting the results. Filter design parameters like cutoff frequencies and approximation errors are specified. The filters are also converted to other forms and their impulse and step responses analyzed.

Uploaded by

Oral Robertz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

[N1,omc]=buttord(omp,oms,ap,as,'s'); [N1,omc]=buttord(omp,oms,ap,as,'s'); N1,omc]=buttord(omp,oms,ap,as,'s');

N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s');


hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50;
[h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w);
m=20*log10(abs(h)); m=20*log10(abs(h)); m=20*log10(abs(h));
plot(om,m); plot(om,m); plot(om,m);
gp=10^(-ap/20); gp=10^(-ap/20); gp=10^(-ap/20);
ap=-20*log10(gp); ap=-20*log10(gp); ap=-20*log10(gp);
N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s');
N=ceil(N1); N=ceil(N1); N=ceil(N1);
[b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s');
[b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs);
[b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs);
Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi;
[hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w);
m1=20*log10(abs(hz)); m1=20*log10(abs(hz)); m1=20*log10(abs(hz));
plot(om1,m1);ax = gca; plot(om1,m1);ax = gca; plot(om1,m1);ax = gca;
set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3
0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]);
set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8
-6 -3 0]);grid on; -6 -3 0]);grid on; -6 -3 0]);grid on;

[N1,omc]=buttord(omp,oms,ap,as,'s'); [N1,omc]=buttord(omp,oms,ap,as,'s'); [N1,omc]=buttord(omp,oms,ap,as,'s');


N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s');
hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50;
[h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w);
m=20*log10(abs(h)); m=20*log10(abs(h)); m=20*log10(abs(h));
plot(om,m); plot(om,m); plot(om,m);
gp=10^(-ap/20); gp=10^(-ap/20); gp=10^(-ap/20);
ap=-20*log10(gp); ap=-20*log10(gp); ap=-20*log10(gp);
N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s');
N=ceil(N1); N=ceil(N1); N=ceil(N1);
[b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s');
[b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs);
[b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs);
Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi;
[hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w);
m1=20*log10(abs(hz)); m1=20*log10(abs(hz)); m1=20*log10(abs(hz));
plot(om1,m1);ax = gca; plot(om1,m1);ax = gca; plot(om1,m1);ax = gca;
set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3
0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]);
set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8
-6 -3 0]);grid on; -6 -3 0]);grid on; -6 -3 0]);grid on;

[N1,omc]=buttord(omp,oms,ap,as,'s'); [N1,omc]=buttord(omp,oms,ap,as,'s'); [N1,omc]=buttord(omp,oms,ap,as,'s');


N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s'); N=ceil(N1);[b,a]=butter(N,omc,'s');
hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50; hs=tf(b,a);pzmap(hs);w=0:50;
[h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w); [h,om]=freqs(b,a,w);
m=20*log10(abs(h)); m=20*log10(abs(h)); m=20*log10(abs(h));
plot(om,m); plot(om,m); plot(om,m);
gp=10^(-ap/20); gp=10^(-ap/20); gp=10^(-ap/20);
ap=-20*log10(gp); ap=-20*log10(gp); ap=-20*log10(gp);
N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s'); N1=cheb1ord(omp,oms,ap,as,'s');
N=ceil(N1); N=ceil(N1); N=ceil(N1);
[b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s'); [b,a]=cheby1(N,ap,omp,'s');
[b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs); [b1,a1] = bilinear(b,a,Fs);
[b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs); [b1,a1] = impulse(b,a,Fs);
Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi; Hz=tf(b1,a1,T);w=0:0.01:pi;
[hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w); [hz,om1]=freqz(b1,a1,w);
m1=20*log10(abs(hz)); m1=20*log10(abs(hz)); m1=20*log10(abs(hz));
plot(om1,m1);ax = gca; plot(om1,m1);ax = gca; plot(om1,m1);ax = gca;
set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3 set(ax,'XTick',[0 pi/12 pi/6 pi/5 pi/4 pi/3
0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]); 0.4*pi 5*pi/12 pi/2 7*pi/12 2*pi/3 3*pi/4 pi]);
set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8 set(ax,'YTick',[-22 -20 -18 -16 -14 -12 -10 -8
-6 -3 0]);grid on; -6 -3 0]);grid on; -6 -3 0]);grid on;

You might also like