# [SciPy-user] Convolve an input with a seri of impulses

Ivo Maljevic ivo.maljevic@gmail....
Mon Apr 20 12:53:49 CDT 2009

```In general, you would do it the same way you would in Matlab:

1) create a sequence of pulses
2) add zeros in between (e.g., using kron function)

Mybe you will find this simple example useful:

Ivo

#!/usr/bin/python

# import
from scipy import *
from pylab import *

L = 50
A_1 = 1
A_2 = -2

# one pulse
pulse_vec = zeros(L)
pulse_vec[0] = 1

#sequence of pulses
my_seq = array([A_1, A_2])
my_pulses = kron(my_seq, pulse_vec)
t = linspace(0,10,2000);
h = 0.1*exp(-t);

# just copy. No need for this in general
x = my_pulses[:]
print x

y = convolve(h,x)
subplot(211)
plot(x)
grid(True)
title('two pulses')
subplot(212)
plot(y)
title('output')
grid(True)
show()

2009/4/20 Mickael <mickael.paris@gmail.com>

> Hi,
>
> I'm trying to convolve a reference signal, like a step signal, with a
> sequence of impulses.  Impulses have different amplitudes and timing :
>
>
> ----------------------------------------------------------------------------
> zeta = 0.0193
> wn = 35037.0
> wd = wn*math.sqrt(1.0-zeta**2)
> K = math.exp(((-zeta*pi)/math.sqrt(1.0-zeta**2)))
>
> num = array([9.871])
> den = array([1,1354,1.228*10**9])
> H = signal.lti(num, den)
>
> # Impulses : amplitudes
> A1 = (1.0/(1.0+K))
> A2 = (K/(1.0+K))
> # Impulses : timing
> t1 = 0
> t2 = (pi/wd)
>
> -----------------------------------------------------------------------------
>
> I would like to apply to "H" the result of a step signal convolve with
> these two pulses but I'don't know to define the vector of the impulses.
> --->T,yout,xout = signal.lsim(H, entree, t)  <=== entree = scipy.signal.
> convolve(*A_step*, My_Impulses?, mode='full')
>
> Thanks,
>
> Mickael.****
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090420/2168a58b/attachment.html
```