%% wave1d
%% show 1D pure wave forms and aliasing
 
%define sample rates and frequency
function wave1d(N,cN);

% N = number of discrete samples
% cN = 'continuous' or fine sampling rate
tN = (0:1:(N-1))/N;  % discrete time points
tcN = (0:1:(cN-1))/cN;  % continuous or fine sampling time points   
K = 2*N;  % number of displays
i = sqrt(-1);

% display results 
for k = 0:2*N 
   sampwave = exp(2*pi*i*k*tN);
   wave = exp(2*pi*i*k*tcN);
   subplot(2,1,1)
    plot(tcN,real(wave),'-r',tN,real(sampwave),'o');
    axis([-0.1,1.1,-1.1,1.1]);
    title('real part');
    drawnow
   subplot(2,1,2)
    plot(tcN,imag(wave),'-g',tN,imag(sampwave),'o');
    axis([-0.1,1.1,-1.1,1.1]);
    title('imaginary part')
    drawnow;
   disp(['k=',num2str(k),', press a key']) 
   pause
   end

