clc
clear all; close all
alpha=0.5; 
%Z=[1 1/alpha]; P=[1 alpha];
%Z=[1 0 0 1/alpha]; P=[1 0 0 alpha]; %working as all-pass
Z=[1 0 0 0 0 0 0 0 1/alpha]; P=[1 0 0 0 0 0 0 0 alpha]; %working as all-pass
%roots(Z); roots(P)
x=zeros(1024,1);
x(1)=1;
q=filter(1,P,x);
y = filter(Z,P,x);

disp(sprintf('n & x & q & y'))
for n=1:8:90
disp(sprintf('%d & %g & %g & %g',n,x(n),q(n),y(n)))
end

N=1:length(x);
%disp([N' x q y])

fig(1);
pltfast(fast(q));
ylabel('Q(\omega)')
xlabel('frequency')
grid on;

fig(2)
pltfast(fast(y));
ylabel('Y(\omega)')
xlabel('frequency')
grid on;

fig(3)
plot(roots(Z),'o'); hold on
plot(roots(P),'xr');
title('Poles & zeros')

R=exp(j*2*pi*(0:.01:1));
plot(R,'k:'); grid on
axis([-1.2 1.2 -1.2 1.2]); axis square

fig(4)
Y=fast(y);
pltfast(real(Y),1,'-b');hold on
pltfast(imag(Y),1,'--r')
title('Re (blue) and Im Y (red) vs freq');
grid on;
%axis([1e])
ylim([0.1 2.1])
