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

figure(3);
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:49, z(1:50).^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_3.eps');


