Skip to content

Instantly share code, notes, and snippets.

@geekykant
Created October 17, 2019 09:07
Show Gist options
  • Save geekykant/f4bcea094f99df0b0ac29eea77e163a4 to your computer and use it in GitHub Desktop.
Save geekykant/f4bcea094f99df0b0ac29eea77e163a4 to your computer and use it in GitHub Desktop.
clc;
clear all;
close all;
rp = input('Enter the pass band ripple: ');
rs = input('Enter the stop band ripple: ');
wp = input('Enter the pass band freq: ');
ws = input('Enter the pass band freq: ');
fs = input('Enter the sampling freq: ');
w1= (2*wp)/fs;
display('w1');
display(w1);
w2=(2*ws)/fs;
display('w2');
display(w2);
[n,wn]= cheb1ord(w1,w2,rp,rs);
display('The order of filter n');
display(n);
display(wn);
[b,a] = cheby1(n,rp,wn);
display('Numerator coefficients b');
display(a);
w= 0:0.01:pi;
[h,on] = freqz(b,a,w);
m=20*log10(abs(h));
an = angle(h);
display tf(b,a);
subplot(2,2,1);
plot(on/pi,m);
subplot(2,2,2);
plot(on/pi,an);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment