Reputation: 497
I was trying to generate signals into the raw way but I am getting the error below could somebody help me ? And yes I need it into the raw way and after I will generate the spectrum of it. Also, could someone gimme some hints of where could I find good tutorials of fft and electronic signals in python ? I've googled but nothing satisfactory was found. Here is the code:
>>> 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
>>>
Best Matt.
Upvotes: 0
Views: 2854