嘿,我需要帮助编写一个方法,将所有x值绘制成给定的数学函数
def compute(expression): #The expression is where the math function is gonna be placed
print("Evaluerer", expression)
for i in range(0,1001):
x=i/100.0 #This is all the x-values, which needs to be put into the expression
感谢您的回复
答案 0 :(得分:0)
定义你的功能:
def f(x):
return x #put here your expression of f(x)
然后将您的功能绘制如下:
plt.plot([i/100.0 for i in range(0,1001)], map(lambda x: f(x),[i/100.0 for i in range(0,1001)]))