[SciPy-user] extending a 2-dim array ?
Robert Kern
robert.kern at gmail.com
Tue Mar 18 17:40:33 EDT 2008
On Tue, Mar 18, 2008 at 4:34 PM, Stef Mientki <s.mientki at ru.nl> wrote:
> hello,
>
> To combine a number of signals (of possible different length),
> I need to extend a 2-dimensional array.
>
> I succeeded, but it looks much too complex in my opinion:
>
> a_list = [1,2,3,4,5]
> a_vector = array ( a_list )
> b_list = [11,22,33,44,55]
> b_vector = array ( b_list )
>
> ab_array = vstack (( a_vector, b_vector ))
>
> # extend each signal with 1 zero element
> extend = transpose ( vstack ( ( transpose ( ab_array ), zeros ((1,2)) )) )
>
>
> does anyone know a more elegant (= more simple) method ?
Use hstack([ab_array, zeros([2,1])]).
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list