[SciPy-user] how to make vectors and arrays of the same length ?
Stef Mientki
s.mientki at ru.nl
Sat Apr 28 03:46:41 EDT 2007
hello,
I've found a working solution for the problem,
but I'm not happy with it,
because I can't manage to do it without 2 transposes,
and I've the feeling my solution is much too complicated.
So I'ld be much obliged if someone gives me a better solution,
or tell me that this is thé solution.
thanks,
Stef Mientki
# start with a 2-dimensional array
# we want to expand the second index with the last value
a=asarray([[1,2,3],[4,5,6]])
# get the last row
b=asarray(a[:,-1])
# now extend the row with 3 samples
a=a.transpose()
a=vstack((a,b))
a=vstack((a,b))
a=vstack((a,b))
a=a.transpose()
And here is the result
[[1 2 3 3 3 3]
[4 5 6 6 6 6]]
More information about the SciPy-User
mailing list