更新时间:2022-05-06 18:46:01
使用numpy.where. (可选)对浮点数使用指数表示法.
Use numpy.where. Optionally, use exponential notation for floating point numbers.
import numpy as np
def f(x, d, h, L):
return np.where(x < d, h*(x/d), (L - x)/(L - d))
x = np.linspace(0,10,1000)
h = 5e-3
d = 16e-2
L = 64.52e-2
func = f(x, d, h, L)