Create linear spaced vector?

kjm kjmacken at gmail.com
Fri Dec 17 19:39:24 CET 2004


Hi Everyone,

I am trying to port some old MatLab code to python, and am stuck on
how to accomplish something.

I am trying to write a generalized function that will create a
linearly spaced vector, given the start and end point, and the number
of entries wanted.

In MatLab I have this function that I wrote:

[code]

function out = linearspace(x1,x2,n)

out = [x1+ (0:n-2)*(x2 - x1)/(floor(n)-1) x2];

return


[/code]


I have the numeric package, numarray installed, and I think it should
be accomplished easily, but I just can't seem to get the syntax
correct with python.

Any tips would be greatly appreciated.


Thanks



More information about the Python-list mailing list