[英]Step function with linear inteval in numpy
Since the other answer does not implement the function in the question, here is a correct soluton: 由于其他答案未实现问题中的功能,因此这里是正确的解决方案:
import numpy as np
import matplotlib.pyplot as plt
x= np.linspace(0., 50., 1001)
f = lambda x0, x1: np.piecewise(x, [x < x0, (x >= x0) & (x <= x1), x > x1],
[0., lambda x: x/x0, 1.])
plt.plot(x, f(10, 30))
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.