% Part (g)

% By looking it up in the table in the book,
%             s + 1           -2            s - 1
%  X(s) = ------------ + ------------ = ------------
%         (s+1)^2 + 16   (s+1)^2 + 16   (s+1)^2 + 16

b = [ 1 -1 ];
a = [ 1 2 17 ];
pzplot(b,a,-0.5);
title('X(s)');
print X_poles_zeros.eps -deps

omega = [-10:0.5:10];
sigma = -1 + (1/8)*[1:32];
[sigmagrid,omegagrid] = meshgrid(sigma,omega);
sgrid = sigmagrid + j*omegagrid;
X = polyval(b,sgrid) ./ polyval(a,sgrid);
mesh(sigma,omega,abs(X));
title('X(s)');
xlabel('\sigma=\Re\{s\}');
ylabel('\omega=\Im\{s\}');
print X_surf.eps -deps

omega = linspace(-10,10,1000);
x = freqs(b,a,omega);
plot(omega,abs(x));
title('|X(j\omega)|');
xlabel('\omega');
print X_freq.eps -deps

%                s - 1.5
% X(s-0.5) = --------------
%            (s+0.5)^2 + 16
shifted_b = [ 1 -1.5 ];
shifted_a = [ 1 1 16.25 ];

omega = linspace(-10,10,1000);
shifted_x = freqs(shifted_b,shifted_a,omega);
plot(omega,abs(shifted_x));
title('|X(-0.5+j\omega)|');
xlabel('\omega');
print shifted_X_freq.eps -deps

% The peaks on the second, shifted plot are sharper than those on
% the first, and the valley is less sharp; this is consistent with
% the fact that the second plot is a slice taken closer to the
% poles and farther from the zero.
