% code to demonstrate usage of the fast Fourier Transform
% notation generally follows the lecture notes
% you will have to get from the DFT to the power spectrum by yourself

% as a demonstration, set up an oscillation with frequency 1/100 
% we do this in terms of n rather than t, 
% this is equivalent to using a timestep of 1
nmax = 1000;
n = 0:1:nmax;
x = sin(2*pi*n/100);

% calculate Discrete Fourier Transform
dft = fft(x);
freq = n/nmax;
plot(freq,dft)
xlabel('Frequency')
ylabel('x_k')

