clf

b = [1 1 0];
a = [1 -1 1/2];

subplot(221)

zplane(b,a)

ti = title('Poles and zeros of X(z)');
set(ti,'FontSize',16);
set(ti,'FontWeight','bold');

[A,p,k] = residuez(b,a);

K = 2*abs(A(1));
r = abs(p(1));
omega = angle(p(1));
theta = angle(A(1));

n = 0:20;

x = K * r.^n .* cos(omega*n + theta);

subplot(212)
stem(n,x);

hold on
plot([n(1) n(length(n))],[0 0]);
grid

ti = title('x(n)');
set(ti,'FontSize',18);
set(ti,'FontWeight','bold');
xl=xlabel('n');
set(ti,'FontSize',16);
tt=text(18,-1.7,'9/11/00');
set(tt,'FontSize',8);
set(tt,'FontName','Courier');
