%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% GENERATE A SINE AND PLOT ITS SPECTRUM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = 1;          % amplitude
phi = pi/4;     % phase offset (in radians)
f = 2;          % frequency
N=8;            % number of samples; should be a power of 2 
%N =16;         % try this next

x = linspace(0, 2*pi*f*(N-1)/N, N); 
y = A*sin(x+phi);

% Finer discretization for plotting purposes only
xF=linspace(0,2*pi*f,20*N);
yF = A*sin(xF+phi);
figure; plot(xF, yF, 'k');
hold on;

% Plot the samples as vertical stems
stem(x,y,'b', 'filled', 'LineWidth', 2);
xlabel('x');
ylabel('y');
title('The Signal and the Samples');

PlotSpectrum(y,N);