[Numpy-discussion] Matlab -> NumPy translation and indexing
Sven Schreiber
svetosch at gmx.net
Wed Mar 14 10:06:17 EDT 2007
David Koch schrieb:
>
> In Python, I tried:
>
> A = empty((0,0))
> while ....
> A = concatenate((A, array([someScalarValue])), 1)
> end
>
> which returns an error since the shape of the empty A does not match the
> vector I want to concatenate with. Any way to get around this without
> having to use some obscure "if exist A" clause. I am still stuck in my
> Matlab ways - hoping to get rid of them though.
If you want a 1d-array in the end you could try empty(0) to start with,
and then do hstack((A, your_scalar)) or something like that.
hth,
sven
More information about the NumPy-Discussion
mailing list