[SciPy-user] extending a 2-dim array ?
Tue Mar 18 17:22:23 CDT 2008
Robert Kern wrote:
> On Tue, Mar 18, 2008 at 4:34 PM, Stef Mientki <email@example.com> wrote:
>> 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])]).
I thought I had tried that and got an error,
but I must have made a mistake.
It now works like a charm.
More information about the SciPy-user