%% Zeros and Poles of Transfer Function
% Design an 8th-order Chebyshev Type II bandpass filter with a stopband attenuation of 20 dB. Specify the stopband edge frequencies as \pi/8 rad/sample and 5\pi/8 rad/sample.

[b,a] = cheby2(8/2,20,[1 5]/8);

%
% Use zplane to plot the poles and zeros of the transfer function.

zplane(b,a)

%
% Visualize the zero-phase response of the filter. Overlay the unit circle and the pole and zero locations.

[hw,fw] = zerophase(b,a,1024,"whole");

z = roots(b);
p = roots(a);

plot3(cos(fw),sin(fw),hw)
hold on
plot3(cos(fw),sin(fw),zeros(size(fw)),'--')
plot3(real(z),imag(z),zeros(size(z)),'o')
plot3(real(p),imag(p),zeros(size(p)),'x')
hold off
xlabel("Real")
ylabel("Imaginary")
view(35,40)
grid

% Copyright 2019 The MathWorks, Inc.