示例#1
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.  
示例#2
0
>>>>>>> 4893a7473d87cb59df0e6ce3c53da80767f9135d
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
示例#3
0
        g1[2 * i] = 1
        k = k + 1
    elif x1[i] >= 0.4 and x1[i] <= 0.6:
        h1[2 * i] = 1
        l = l + 1
for i in range(N1):
    g1[i] = g1[i] / k
    h1[i] = h1[i] / l

for j in range(N2):
    x2[j] = j * dx2
    if x2[j] <= 0.1:
        g2[2 * j] = 1
        m = m + 1
    elif x2[j] >= 0.4 and x2[j] <= 0.6:
        h2[2 * j] = 1
        n = n + 1
for j in range(N2):
    g2[j] = g2[j] / m
    h2[j] = h2[j] / n

corr1 = correlation(g1, h1)
corr2 = correlation(g2, h2)

fft.plot_c(x1, g1)
fft.plot_c(x1, h1)
fft.plot_c(x1, corr1)
fft.plot_c(x2, g2)
fft.plot_c(x2, h2)
fft.plot_c(x2, corr2)
示例#4
0
        g1[2 * i] = 1
        k = k + 1
    elif x1[i] >= 0.4 and x1[i] <= 0.6:
        h1[2 * i] = 1
        l = l + 1
for i in range(N1):
    g1[i] = g1[i] / k
    h1[i] = h1[i] / l

for j in range(N2):
    x2[j] = j * dx2
    if x2[j] <= 0.1:
        g2[2 * j] = 1
        m = m + 1
    elif x2[j] >= 0.4 and x2[j] <= 0.6:
        h2[2 * j] = 1
        n = n + 1
for j in range(N2):
    g2[j] = g2[j] / m
    h2[j] = h2[j] / n

corr1 = correlation(g1, h1)
corr2 = correlation(g2, h2)

fft.plot_c(x1, g1)
fft.plot_c(x1, h1)
fft.plot_c(x1, corr1)
fft.plot_c(x2, g2)
fft.plot_c(x2, h2)
fft.plot_c(x2, corr2)
示例#5
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()
示例#6
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()
示例#7
0
import fft
import numpy as np
import matplotlib.pyplot as plt
import time

b = [4, 13, 28, 39, 50]
n = len(b)
PI = 2*np.arcsin(1)
N= 64
L = 2*PI
dx = L / (N-1)
x = np.zeros(N)
y = np.zeros(2*N)
f = np.zeros(N)
for j in range(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
  y = fft.fft_slow(y,1.)
  plt.figure(j)
  fft.plot_c(f[:.5*N],y[:N])
  y = fft.fft_slow(y,-1.)
  fft.plot_c(x,y)
plt.show()