整理不易,有条件的点个关注、点个赞呗!感恩各位大哥!
数据案例实现
测试数据采用x=np.linspace(0,1,1400) ,a=7*np.sin(2*np.pi*200*x) + 5*np.sin(2*np.pi*400*x)+3*np.sin(2*np.pi*600*x) 生成的。
import numpy as np
x=np.linspace(0,1,1400)
a=7*np.sin(2*np.pi*200*x) + 5*np.sin(2*np.pi*400*x)+3*np.sin(2*np.pi*600*x)
N=a.shape[0]
temps=[]
for k in range(N):
temp=0
for n in range(N):
wn=complex(np.cos(2.0*k*np.pi*(n/N)),-(np.sin(2.0*k*np.pi*(n/N))))
temp+=a[n]*wn
temps.append(temp)
print(temps[0:5])
输出:
output:
[(-4.217055953999462e-12+0j), (9.66210986046634e-05-0.043057556148230036j), (0.00038650807000099153-0.08611995903966796j), (0.0008697320363069723-0.12919205775395143j), (0.0015464115722406502-0.17227870600313114j)]
其实际过程就是根据下面的公式进行变换:
X
(
k
)
=
∑
n
=
0
N
?
1
x
(
n
)
c
o
s
(
2
π
k
n
N
)
?
j
x
(
n
)
s
i
n
(
2
π
k
n
N
)
X(k)=\sum_{n=0}^{N-1}{x(n)cos(2\pi k\frac{n}{N})-jx(n)sin(2\pi k\frac{n}{N})}
X(k)=n=0∑N?1?x(n)cos(2πkNn?)?jx(n)sin(2πkNn?)
|