Convolution of different sized arrays

Olenka Subota olenkasubota at gmail.com
Tue Jul 26 14:10:01 CEST 2011


Hello all,

I need your help. I have to simulate a filter whose transfer function
is a step fct, and I wrote it as a column-vector of Ns elements :
>>> h=ones(3,dtype=float)
>>> print h
[ 1.  1.  1.]
>>> h=reshape(h,(3,1))
>>> h
array([[ 1.],
       [ 1.],
       [ 1.]])

In this case Ns=3 for simplicity.
The input of my filter is another column-vector of k*Ns elements
(3*3):
x0_vect
array([[ 1.41421356],
       [ 0.        ],
       [ 0.        ],
       [ 1.41421356],
       [ 0.        ],
       [ 0.        ],
       [ 1.41421356],
       [ 0.        ],
       [ 0.        ]])
So I`d like to convolve the two column vectors. Am I going to obtain a
row-vector?
I`ve tried to apply the convolve built-in function but it gives me
this error:
convolve(x0_vect,h)

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    convolve(x0_vect,h)
  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line
787, in convolve
    return multiarray.correlate(a, v[::-1], mode)
ValueError: object too deep for desired array

If anyone of you can help, please do it..
Thanks!



More information about the Python-list mailing list