% MATLAB_EX_1 shows a simple example of fft in practice
%
% file:      	matlab_ex_1.m, (c) Matthew Roughan, Sat Aug  7 2004
% directory:   /home/mroughan/Classes/Transformations/2004/Matlab/
% 
%
f_s = 1000;            % sampling frequency
f_0 = 100;             % frequency of the signal
x = 1:1/f_s:10;        % sample points
N = length(x);
y = sin(2*pi*f_0*x);   % sampled signal
semilogy(-f_s/2+f_s/N:f_s/N:f_s/2, abs(fftshift(fft(y))).^2, 'linewidth', 3);

%%%% make the axes pretty and add labels
grid on
set(gca, 'ylim', 10.^[-2 9], 'ytick',  10.^[-2:2:9], 'xtick', [-500:200:500]);
set(gca, 'linewidth', 3, 'fontsize', 18);
xlabel('frequency (Hz)');

%%%% print out a copy
print('-depsc', 'Plots/matlab_ex_1.eps');

