我的fft Python中的错误问题,怎么解决
展开全部
Your error might come from the way you define x(t) :
x_t = cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t))) #Define x(t)
acc = lambda t: (x_t) #Define x[t] in terms of t as a variable in Python's eyes
When Python executes the first line, it assigns to the variable x_t
the value of the formula you're given it using the current value of t ( scipy.linspace(0.01, 32/390625, samples, False) ). It doesn't interpret t as a variable.
To fix this change the second line by this :
acc = lambda t: cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t)))
EDIT : Just noticed you did the same with signal. Writing : signal = acc(t) (even if you fixed acc) will just assign the result of the function acc(t)
(with the current value of t) to the variable signal. It won't be a
function. (Why don't you just use acc instead of signal as acc is a
function of t anyway ?)
x_t = cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t))) #Define x(t)
acc = lambda t: (x_t) #Define x[t] in terms of t as a variable in Python's eyes
When Python executes the first line, it assigns to the variable x_t
the value of the formula you're given it using the current value of t ( scipy.linspace(0.01, 32/390625, samples, False) ). It doesn't interpret t as a variable.
To fix this change the second line by this :
acc = lambda t: cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t)))
EDIT : Just noticed you did the same with signal. Writing : signal = acc(t) (even if you fixed acc) will just assign the result of the function acc(t)
(with the current value of t) to the variable signal. It won't be a
function. (Why don't you just use acc instead of signal as acc is a
function of t anyway ?)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询