Python linspace array
The linspace() function is used to create an array with evenly spaced points between a starting point and ending point .
Array linspace() function
linspace(start, stop, n)
'start ' represents the starting element and 'stop' represents the ending element. 'n' is an integer that represents the number of parts the elements should be divided. If 'n' is omitted, then it is taken as 50. Let's take one example to understand this.
a = linspace(0, 10, 5)
In the above statement, we are creating an array 'a' with starting element 0 and ending element 10. This range is divided into 5 equal parts and hence the points will be 0, 2.5, 5, 7.5 and 10. These elements are stored into 'a'. Remember the elements 0 and 10 are included.
linspace array examples:Python program to creating an array with 5 equal points using linspace().
from numpy import * a = linspace(0, 10, 5) print('a =', a)