【发布时间】:2017-04-29 21:32:55
【问题描述】:
import math
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-4,5,1)
y=(math.sqrt(math.cos(x)))*(math.cos(300*x))+(math.sqrt(abs(x))-0.7*(4-x*x)**0.1)
plt.plot(x,y)
plt.show()
我想绘制这个函数。这很简单,但我遇到了麻烦。当我运行程序时,它说:
File "funct.py", line 7, in <module>
y=(math.sqrt(math.cos(x)))*(math.cos(300*x))+(math.sqrt(abs(x))-0.7*(4-x*x)**0.1)
TypeError: only length-1 arrays can be converted to Python scalar
【问题讨论】:
标签: python