I have calculated the coefficients of the discrete Fourier transform of a function. I have also created an array of N=1000 elements containing 1000 equally spaced samples from a single cycle of a square wave.
here is my code
F=zeros(1000)
F[0:500]=1
F[500:1000]=-1
a = rfft(F)
print a
How do I set all but the first 10 Fourier coefficients to zero ?