使用 Python 生成信号

Generating Signals with Python

我试图以原始方式生成信号,但出现以下错误有人可以帮助我吗?是的,我需要它以原始方式生成它的频谱。另外,有人可以给我一些提示,告诉我在哪里可以找到 python 中 fft 和电子信号的好教程吗?我用谷歌搜索但没有找到令人满意的东西。 这是代码:

>>> import numpy as np
>>> f = 10
>>> w = 2.*np.pi*f
>>> time_interval = 100
>>> samples = 5000
>>> t = np.linspace(0,time_interval,samples)
>>> t
array([ 0.00000000e+00, 2.00040008e-02, 4.00080016e-02, ...,
9.99599920e+01, 9.99799960e+01, 1.00000000e+02])
>>> y1 = np.sin(w*t)
>>> y2 = np.sin(2.*w*t)
>>> y1
array([ 0.00000000e+00, 9.51134166e-01, 5.87378440e-01, ...,
-5.87378440e-01, -9.51134166e-01, -6.42833292e-13])
>>> y2
array([ 0.00000000e+00, 5.87378440e-01, -9.50745316e-01, ...,
9.50745316e-01, -5.87378440e-01, -1.28566658e-12])
>>> y1c = np.array(y1[:])
>>> y1c
array([ 0.00000000e+00, 9.51134166e-01, 5.87378440e-01, ...,
-5.87378440e-01, -9.51134166e-01, -6.42833292e-13])
>>> y2c = np.array(y2[:])
>>> y2c
array([ 0.00000000e+00, 5.87378440e-01, -9.50745316e-01, ...,
9.50745316e-01, -5.87378440e-01, -1.28566658e-12])
>>> yc = np.concatenate(y1c,y2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: only length-1 arrays can be converted to Python scalars
>>>

最佳马特

concatenate 取一个元组:

yc = np.concatenate((y1c, y2c))