% file:      	fft_sin_2.m, (c) Matthew Roughan, Sun Jun 27 2004
x = (0:0.01:1);
f1 = 7;              % frequency 1 = 7 Hz
f2 = 15;             % frequency 2 = 15 Hz
y = sin(2*pi*f1 * x) + sin(2*pi*f2 * x);

figure(2);
subplot(2,1,1)
hold off
plot(x, y, 'linewidth', 3);
set(gca,'xlim', [0 max(x)]);
set(gca,'linewidth', 3, 'fontsize', 18);
xlabel('time (seconds)');

z = abs(fft(y));
subplot(2,1,2)
hold off
stem(0:(length(z)-3)/2, z(1:end/2).^2, 'linewidth', 3);
set(gca,'linewidth', 3, 'fontsize', 18);
xlabel('frequency (Hz)');

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperPosition', [0 0 20 11.5])
print('-depsc', 'Plots/fft_sin_2.eps');
