假
设
:
f
1
=
10
;
f
2
=
20
;
f
3
=
30
假设: f1 = 10; f2 = 20; f3 = 30
假设:f1=10;f2=20;f3=30
y
=
s
i
n
(
2
∗
p
i
∗
f
1
∗
t
)
+
2
∗
s
i
n
(
2
∗
p
i
∗
f
2
∗
t
)
+
3
∗
s
i
n
(
2
∗
p
i
∗
f
3
∗
t
)
y = sin(2*pi*f1*t) + 2*sin(2*pi*f2*t) + 3*sin(2*pi*f3*t)
y=sin(2∗pi∗f1∗t)+2∗sin(2∗pi∗f2∗t)+3∗sin(2∗pi∗f3∗t)
F
r
e
q
u
e
n
c
y
S
a
m
p
l
e
(
f
s
)
=
128
,
L
e
n
g
t
h
(
T
)
=
5
;
注
意
此
处
的
采
样
点
数
要
满
足
奈
奎
斯
特
准
则
FrequencySample(fs) = 128,Length(T)=5;注意此处的采样点数要满足奈奎斯特准则
FrequencySample(fs)=128,Length(T)=5;注意此处的采样点数要满足奈奎斯特准则
S
u
m
m
a
t
i
o
n
L
e
n
g
t
h
(
N
)
=
f
s
∗
T
=
128
∗
5
Summation Length(N) = fs*T = 128 * 5
SummationLength(N)=fs∗T=128∗5
FFT后的频域转化公式为
F
i
=
∑
1
<
=
i
<
=
N
i
N
∗
f
s
F_i = \sum\limits_{1<=i<=N} \dfrac{i}{N} * fs
Fi=1<=i<=N∑Ni∗fs
FFT后的幅值转化公式为, Ai为傅里叶变换后的第i个值
A
i
=
∑
1
<
=
i
<
=
N
∣
A
i
∣
2
N
A_i = \sum\limits_{1<=i<=N} |A_i| \dfrac{2}{N}
Ai=1<=i<=N∑∣Ai∣N2
双边傅里叶变换频率
from matplotlib.pyplot import plot, show, subplot
from numpy import pi, sin, linspace
from numpy.fft import fft, fftfreq
fs = 128
T = 5
f1 = 10
f2 = 20
f3 = 30
t = linspace(0, T, T*fs)
y = sin(2*pi*f1*t) + 2*sin(2*pi*f2*t) + 3*sin(2*pi*f3*t)
x = fftfreq((len(t))) * fs
subplot(121)
plot(t, y)
subplot(122)
plot(x, abs(fft(y)) / len(t) * 2)
show()
单边傅里叶变换频率
from matplotlib.pyplot import plot, show, subplot
from numpy import pi, sin, linspace
from numpy.fft import fft, fftfreq
fs = 128
T = 5
f1 = 10
f2 = 20
f3 = 30
t = linspace(0, T, T*fs)
y = sin(2*pi*f1*t) + 2*sin(2*pi*f2*t) + 3*sin(2*pi*f3*t)
x = fftfreq((len(t))) * fs
subplot(121)
plot(t, y)
subplot(122)
plot(x[:len(x)//2], abs(fft(y))[:len(x)//2] / len(t) * 2)
show()