Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在实数(0,pi)的间隔上创建一个具有 N 个点的均匀一维网格。目前我有以下工作代码:
import numpy as np u = np.linspace(0, np.pi, N+1, endpoint = False) u = u[1:]
我可以避免最后一行吗?似乎没有startpoint与上述等效的选项endpoint。
startpoint
endpoint
干得好:
np.linspace(np.pi/(N+1), np.pi, N, endpoint = False)
通过显式计算第一个点,这给出了与您的代码相同的结果。不过,我并不认为这种方式比您的原始代码更好。