python numpy linspace
时间: 2023-09-21 22:05:23 浏览: 125
numpy.linspace函数具体使用详解
numpy.linspace() is a function in the numpy library of python programming language that generates evenly spaced numbers over a specified interval. The function takes three arguments: start, stop, and num.
Syntax: numpy.linspace(start, stop, num)
where,
- start: The starting value of the sequence.
- stop: The end value of the sequence.
- num: The number of evenly spaced samples to be generated.
The function returns an array of num evenly spaced values between start and stop.
Example:
import numpy as np
x = np.linspace(0, 10, 5)
print(x)
Output:
[ 0. 2.5 5. 7.5 10. ]
阅读全文