Example #1
0
x = np.zeros(N)
f = np.zeros(N)
y = np.zeros(2*N)

for i in range(N):
<<<<<<< HEAD
  x[i] = i * dx
=======
  x[i] = i*dx
>>>>>>> 4893a7473d87cb59df0e6ce3c53da80767f9135d
  f[i] = i
  y[2*i] = np.sin(x[i]) + np.sin(4.*x[i])
  y[2*i+1] = 0

fft.plot_c(x,y)
y = fft.fft_slow(y,1.)
<<<<<<< HEAD
fft.plot_c(f[:0.5*N],y)[:N]


plt.show()

=======
fft.plot_c(f[:0.5*N],y[:N])
y = fft.fft_slow(y,-1.)
fft.plot_c(x,y)

#plt.plot(x,y)
plt.show()
>>>>>>> 4893a7473d87cb59df0e6ce3c53da80767f9135d
Example #2
0
#!/usr/bin/env python
import fft
import numpy as np
import matplotlib.pyplot as plt
import time

PI = 2 * np.arcsin(1)
N = 64
L = 2 * PI
dx = L / (N - 1)
x = np.zeros(N)
f = np.zeros(N)
y = np.zeros(2 * N)

for i in range(N):
    x[i] = i * dx
    f[i] = i
    y[2 * i] = np.sin(x[i]) + np.sin(4. * x[i])
    y[2 * i + 1] = 0

fft.plot_c(x, y)
y = fft.fft_slow(y, 1.)
fft.plot_c(f[:0.5 * N], y[:N])
y = fft.fft_slow(y, -1.)
fft.plot_c(x, y)

#plt.plot(x,y)
plt.show()
Example #3
0
x = np.zeros(N)
f = np.zeros(N)
y_1 = np.zeros(N)
y_2 = np.zeros(N)
y_3 = np.zeros(N)
y_4 = np.zeros(N)
y_5 = np.zeros(N)

for i in range(N):
  x[i] = i*dx
  f[i] = i
  y_1[i] = np.sin(x[i]) + np.sin(b[0]*x[i])
  y_2[i] = np.sin(x[i]) + np.sin(b[1]*x[i])
  y_3[i] = np.sin(x[i]) + np.sin(b[2]*x[i])
  y_4[i] = np.sin(x[i]) + np.sin(b[3]*x[i])
  y_5[i] = np.sin(x[i]) + np.sin(b[4]*x[i])

y_1 = fft.fft_slow(y_1,1.)
fft.plot_c(f[:0.5*N],y_1[:N])
y_2 = fft.fft_slow(y_2,1.)
fft.plot_c(f[:0.5*N],y_2[:N])
y_3 = fft.fft_slow(y_3,1.)
fft.plot_c(f[:0.5*N],y_3[:N])
y_4 = fft.fft_slow(y_4,1.)
fft.plot_c(f[:0.5*N],y_4[:N])
y_5 = fft.fft_slow(y_5,1.)
fft.plot_c(f[:0.5*N],y_5[:N])

#At the different spectra, the peaks moved to the higher frequencies until
#they reached b=39.  
Example #4
0
#!/usr/bin/env python
import fft
import numpy as np
import matplotlib.pyplot as plt
import time

b=np.array([4,13,28,39,50])
n=len(b)
for j in range(n):
 PI = 2*np.arcsin(1)
 N = 64
 L = 2*PI
 dx = L / (N-1)
 x = np.zeros(N)
 f = np.zeros(N)
 y = np.zeros(2*N)
 
 for i in range(N):
   x[i] = i*dx
   f[i] = i
   y[2*i] = np.sin(x[i]) + np.sin(b[j]*x[i])
   y[2*i+1] = 0
 
 #fft.plot_c(x,y)
 y = fft.fft_slow(y,1.)
 fft.plot_c(f[:0.5*N],y[:N])

#plt.plot(x,y)
plt.show()