clear all; close all

T=20;
n=2^7;
m=n/2;

x=linspace(-T/2,T/2,n+1);
xd=x(1:n); % the n data points for interpolation
fd=exp(-xd.^2); % f evaluated at the data points
plot(xd,fd)

c_raw=fft(fd);
figure(2) % plot the raw unscaled unshifted coeffs
subplot(3,1,1), plot(real(c_raw))
subplot(3,1,2), plot(imag(c_raw))
subplot(3,1,3), plot(abs(c_raw))

fc=fftshift(c_raw)/n;
figure(3) % plot c_k versus k=-m,...,-1,0,1,...m-1
subplot(3,1,1), plot(-m:m-1,real(fc))
subplot(3,1,2), plot(-m:m-1,imag(fc))
subplot(3,1,3), plot(-m:m-1,abs(fc))

F= ifft( ifftshift(n*fc) ); % transform back to original function
figure(4), plot(xd,F)


