xvals = 1:100;
y = 20*cos(2*pi*0.05*xvals)+cos(2*pi*0.15*xvals);
n = size(y, 2);
I1 = abs(fft(y)/sqrt(n)).^2;
P1 = I1*4/n;

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

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

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

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

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