xvals = 1:100;
y2 = 20*cos(2*pi*(1/22)*xvals)+cos(2*pi*0.15*xvals);
n = size(y2, 2);
I2 = abs(fft(y2)/sqrt(n)).^2;
P2 = I2*4/n;

subplot(2, 1, 1)
plot((1:50)/100, P2(1:50), '-k', 'LineWidth', 2)

set(gca, 'Box', 'off', 'FontSize', 20, ...
         'XLim', [-0.01, 0.51], 'YLim', [-10, 220], ...
         'XTick', 0:0.1:0.5, 'YTick', 0:50:200, ...
         'TickDir', 'out')
xlabel('Frequency', 'FontSize', 20)

subplot(2, 1, 2)
plot((1:50)/100, log10(P2(1:50)), '-k', 'LineWidth', 2)

set(gca, 'Box', 'off', 'FontSize', 20, ...
         'XLim', [-0.01, 0.51], 'YLim', [-1.1, 2.5], ...
         'XTick', 0:0.1:0.5, 'YTick', -1:1:2, ...
         'TickDir', 'out')
xlabel('Frequency', 'FontSize', 20)

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