%% Impulse invariance
alpha = exp(-1000 * T);
h_n = 1000 * (alpha.^n);
% Plotting Digital Impulse Response
figure
stem(n, h_n, 'filled')
xlabel('n')
ylabel('h[n]')
title('Digital Impulse Response')
%% Pole-Zero Map (z-plane)
figure
plot(alpha, 0, 'x', 'MarkerSize', 10, 'LineWidth', 2)
xlabel('Re\{z\}')
ylabel('Im\{z\}')
title('Digital Pole-Zero Map')
grid on
%% Sampled inputs
x1n = cos(2*pi*100*td) + cos(2*pi*500*td);
x2n = 2 * exp(-2*td);
%% Discrete convolution
y1n = conv(x1n, h_n, 'same');
y2n = conv(x2n, h_n, 'same');
%% Visualization of Results
figure
% Subplot 1: Periodic Signal
subplot(2,1,1)
stem(n, x1n, 'filled'); hold on
stem(n, y1n, 'r', 'filled')
legend('x_1[n]', 'y_1[n]')
title('Discrete Periodic Signal')
% Subplot 2: Exponential Signal
subplot(2,1,2)
stem(n, x2n, 'filled'); hold on
stem(n, y2n, 'r', 'filled')
legend('x_2[n]', 'y_2[n]')
title('Discrete Exponential Signal')