【Python信号处理】FFT变换后的坐标变换以及绘图

假 设 : 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(2pif1t)+2sin(2pif2t)+3sin(2pif3t)
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)=fsT=1285
FFT后的频域转化公式为
F i = ∑ 1 < = i < = N i N ∗ f s F_i = \sum\limits_{1<=i<=N} \dfrac{i}{N} * fs Fi=1<=i<=NNifs
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<=NAiN2

双边傅里叶变换频率

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()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值