%This script plots a dirichlet kernel and its periodogram.  
x_values = -6:0.01:6;
kernel_values = sin(pi*x_values)./(100*sin(pi*x_values/100));
periodogram_values=abs(sin(pi*x_values)./(100*sin(pi*x_values/100))).^2;

%This corrects a singularity at the center.
kernel_values(find(isnan(kernel_values))) = 1;
periodogram_values(find(isnan(periodogram_values))) = 1;

subplot(2, 1, 1)
plot(x_values, kernel_values, '-k', 'LineWidth', 2)

set(gca, 'Box', 'off', 'FontSize', 20, ...
         'XLim', [-6.1, 6.1], 'YLim', [-0.3, 1.1], ...
         'XTick', -6:2:6, 'YTick', -0.25:0.25:1, ...
         'TickDir', 'out')
xlabel('j', 'FontSize', 20)

subplot(2, 1, 2)
plot(x_values, periodogram_values, '-k', 'LineWidth', 2)

set(gca, 'Box', 'off', 'FontSize', 20, ...
         'XLim', [-6.1, 6.1], 'YLim', [-0.1, 1.1], ...
         'XTick', -6:2:6, 'YTick', 0:0.25:1, ...
         'TickDir', 'out')
xlabel('j', 'FontSize', 20)

set(gcf, 'Position', [200, 100, 1200, 800])