% Surface plot of a TF in z domain
clear
hold off
num=[1 1 0];
den=[1 -2*0.9*.924 0.9^2];
TF=filt(num,den);
r=0:.02:1;
theta=[0:.05:2*pi 2*pi];
%real=-1.2:.1:1.2;
%imag=-1.2:.1:1.2;
real=[];
imag=[];
mag=zeros(length(theta),length(r));
for k=1:length(r)
   mag(:,k)=(abs(POLYVAL(num,r(k)*exp(j*theta))./POLYVAL(den,r(k)*exp(j*theta))))';
   real=[real r(k)*cos(theta)'];
   imag=[imag r(k)*sin(theta)'];
end
% unit circle
realcirc=real(:,length(r));
imagcirc=imag(:,length(r));
%shading faceted
%colormap([0 0 0; 0 0 0]);
mesh(real,imag,mag);
caxis([0 30])
axis([-1 1 -1 1 0 20])
hold on
colormap([[0.3:.001:1]' [0.3:.001:1]' [0.3:.001:1]']);
surf(real,imag,mag);
caxis([0 30])
plot(realcirc,imagcirc)
plot([0.9*cos(pi/8) 0.9*cos(-pi/8)],[0.9*sin(pi/8) 0.9*sin(-pi/8)],'x')
