Dear all,
Can someone identify the error in my code, I wanted to plot the frequency response of this chebyshev filter with the cutt off frequency. It is giving error. Any response!
Code:
n = input('\n Enter the order of Chebyshev filter : ');
eibsln = input('\n Enter the ripple factor of the passband : ');
fc = input('\n Enter the Cutt off frequency for your filter:');
ripples=10*log(1+ eibsln.^2);
Bw=2*pi*fc
Cheb_P=ChebyshevPoly
T_NB2=conv(Cheb_P,Cheb_P)
T_NB2EPS= (eibsln^2).* (T_NB2)
T_NB2EPS2=T_NB2EPS;
T_NB2EPS2(end)=T_NB2EPS(end)+1
% Get the poles
thepolesOmega=roots(T_NB2EPS2);
thepoles=j*thepolesOmega
thepoles_s=thepoles* Bw
hh =find(real(thepoles_s)<0)
stpoles = thepoles_s(hh) % Stable Poles
den1 = poly(stpoles)
den2 = real(den1)
H1 = tf(1,den2) % Transfer function
A=den2
p=polyfact(A)
p_size=ones(size(p))
num = num2cell(p_size);
H2= tf(num,p)
grid on
numer=1;
[numer,den2]= cheby1(n,ripples,1,'s') % Wc = 1 [rad/s]
ww = logspace(-1,1);
h_norm = freqs(num,den2,ww)
mag = abs(h_norm);
mag = 20*log10(mag);
phase = unwrap(angle(h_norm))*180/pi;
% to display axis with fc [Hz]
f_ww= ww* 2*pi ;
subplot(2,1,1), semilogx(f_ww,mag)
subplot(2,1,2), semilogx(f_ww,phase)
Results:
Error in ==> auto_cheby_testing at 38
h_norm = freqs(num,den2,ww)