0

I know it is possible to create numpy arrays using the Linspace function. For example, given a range [x,y] I can make a vector of z elements equally distanced in [x,y]

v = np.linspace(x, y, z, retstep=True)

What if one needs more dimensions? Is it possible to use the same function to generate a 3x4 array? I tried by creating simple arrays and then merge them, but I don't think that is an efficient way to do that

1
  • 1
    linspace lets you use arrays for x and y. It in effect makes the z element array, and scales to fit between the matching x and y values. Commented Mar 15, 2021 at 18:47

1 Answer 1

0

You can use arrays for start and stop point of linspace:

x=np.linspace((0,0,0), (3,5,14), 4, axis=1)
print(x)

This will give the output:

[[ 0.          1.          2.          3.        ]
 [ 0.          1.66666667  3.33333333  5.        ]
 [ 0.          4.66666667  9.33333333 14.        ]]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.