def rect(t,tau):
x = np.zeros(len(t))<EOL>for k,tk in enumerate(t):<EOL><INDENT>if np.abs(tk) > tau/<NUM_LIT>:<EOL><INDENT>x[k] = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>x[k] = <NUM_LIT:1><EOL><DEDENT><DEDENT>return x<EOL>
Approximation to the rectangle pulse Pi(t/tau).

In this numerical version of Pi(t/tau) the pulse is active
over -tau/2 <= t <= tau/2.

Parameters
----------
t : ndarray of the time axis
tau : the pulse width

Returns
-------
x : ndarray of the signal Pi(t/tau)

Examples
--------
>>> import matplotlib.pyplot as plt
>>> from numpy import arange
>>> from sk_dsp_comm.sigsys import rect
>>> t = arange(-1,5,.01)
>>> x = rect(t,1.0)
>>> plt.plot(t,x)
>>> plt.ylim([0, 1.01])
>>> plt.show()

To turn on the pulse at t = 1 shift t.

>>> x = rect(t - 1.0,1.0)
>>> plt.plot(t,x)
>>> plt.ylim([0, 1.01])