[Numpy-discussion] creating column vectors

Stefan van der Walt stefan at sun.ac.za
Wed Feb 8 12:25:02 EST 2006


On Wed, Feb 08, 2006 at 06:44:54PM +0100, Sven Schreiber wrote:
> Gerard Vermeulen schrieb:
> 
> >> mat(arange(1,10)).transpose()
> >>
> >> works, but seems a bit long-winded (in comparison to MATLAB's [1:10]').
> 
> > 
> > What about this?
> > 
> > arange(1, 10)[:, NewAxis]
> > 
> 
> The numpy-book beats both of us (see my previous post) in terms of
> minimal typing overhead by suggesting r_[1:10,'c'] which produces a
> matrix type, very nice.

Thanks for your effort, that's exactly what I was looking for!  Time
to get hold of that book...

Cheers
Stéfan




More information about the NumPy-Discussion mailing list