AWe distinguish real and complex signals. A real valued signal x is a mapping from time
A complex valued signal $x$ is a mapping from
When using computers we start to represent signal with a discrete and countable stream of numbers: we call these numbers signal samples. At every time instance
Plotting real values signals¶
Consider a CT signal
t = np.linspace[-0.02, 0.05, 1000] plt.plot[t, 325 * np.sin[2*np.pi*50*t]]; plt.xlabel['t']; plt.ylabel['x[t]']; plt.title[r'Plot of CT signal \$x[t]=325 \sin[2\pi 50 t]\$']; plt.xlim[[-0.02, 0.05]]; #@savefig sineplot.png plt.show[]
[Source code, png, hires.png, pdf]
Evidently the above plot is a lie. You cannot plot a CT signal on a digital device. In Computer Graphics class you have or will learn that a function [signal] is plotted as a chain of straight lines [and even the straight lines are discretized as a set of dots]. But it sure looks like a CT signal doesn’t it?
Things are different when we consider a DT signal. Given the values of
Therefore a DT signal is plotted as a sequence of vertical bars. A stem plot:
n = np.arange[50]; dt = 0.07/50 x = np.sin[2 * np.pi * 50 * n * dt] plt.xlabel['n']; plt.ylabel['x[n]']; plt.title[r'Plot of DT signal \$x[n] = 325 \sin[2\pi 50 n \Delta t]\$']; #@savefig dtsineplot.png plt.stem[n, x];
[Source code, png, hires.png, pdf]
Plotting Complex Valued Signals¶
Now consider the complex valued CT signal:
Plotting such a signal as if it were a real valued signal results in a Python warning that complex numbers are casted to real by discarding the imaginary parts. To see everything we have to plot both the real and imaginary part of the signal.
t = np.linspace[-0.02, 0.05, 1000] plt.subplot[2,1,1]; plt.plot[t, np.exp[2j*np.pi*50*t].real ]; plt.xlabel['t']; plt.ylabel['Re x[t]']; plt.title[r'Real part of \$x[t]=e^{j 100 \pi t}\$']; plt.xlim[[-0.02, 0.05]]; plt.subplot[2,1,2]; plt.plot[t, np.exp[2j*np.pi*50*t].imag]; plt.xlabel['t']; plt.ylabel['Im x[t]']; plt.title[r'Imaginary part of \$x[t]=e^{j 100\pi t}\$']; plt.xlim[[-0.02, 0.05]]; #@savefig csineplot.png plt.show[]
[Source code, png, hires.png, pdf]
Instead of plotting the real and imaginary part of a complex signal, we can also plot the magnitude and angle of the complex values.
t = np.linspace[-0.02, 0.05, 1000] plt.subplot[2,1,1]; plt.plot[t, np.abs[np.exp[2j*np.pi*50*t]] ]; plt.xlabel[r'\$t\$']; plt.ylabel[r'\$|x[t]|\$']; plt.title[r'Absolute value of \$x[t]=e^{j 100 \pi t}\$']; plt.xlim[[-0.02, 0.05]]; plt.subplot[2,1,2]; plt.plot[t, np.angle[np.exp[2j*np.pi*50*t]]*360/[2*np.pi]]; plt.xlabel['\$t\$']; plt.ylabel[r'\$\angle x[t]\$']; plt.title[r'Phase of \$x[t]=e^{j 100 \pi t}\$']; plt.xlim[[-0.02, 0.05]]; #@savefig cabsanglesineplot.png plt.show[]
[Source code, png, hires.png, pdf]
Note that both plots of the complex signal are equivalent. They both do represent the same signal. Also note the seemingly strange behaviour of the phase [angle] plot. It looks quite discontinuous. But it is really not because the phase jumps from +180 degrees to -180 degrees and that is of course the same angle! This phenomenon will be seen quite a lot when plotting the phase of complex signals and functions. It is called phase wrapping. If we would allow angles outside the range from -180 to +180 we could obtain a perfectly straight line [doing just that is called phase unwrapping].
A few special functions¶
In DSP we use some special functions:
1. Constant signal
Constant Function¶**2. Step function **
A step function is like a light switch which is turned on at t = 0.
Step Function¶3. Pulse function
The pulse function, also called the impulse function, in DT is easy: everywhere zero except at $n=0$ where the values is
In CT it is more difficult. The pulse in CT is written as
property:
A usefull way to think about a pulse signal is to consider a signal in which you want to concentrate a finite amount of energy in a short a time interval as possible. Energy in a signal is measured by integrating a signal over a period of time.
onsider for instance the signal $x_a[t]$ defined as:
The total energy in this signal is $1$ [the integral of $x[t]$ over the entire domain]. This is true irrespective of the value of $a$. In the limit when $arightarrow0$ the value
The strange thing thus is that the function value is infinite [well more accurate said it is not well defined] at $t=0$ whereas the integral over the entire domain is finite and equal to 1.
We will see many uses of the pulse function. The translated CT pulse function
n = np.arange[10]; x = np.zeros_like[n]; x[2]=3; plt.vlines[n,0,x,'b']; plt.ylim[-1,4]; plt.plot[n,0*n, 'b']; #@savefig pulseplot.png plt.show[];
[Source code, png, hires.png, pdf]
The straight line indicates it is a pulse and the length of the line indicates the total energy.
Pulse Function¶Exercises¶
Write Python functions to plot signals/functions like the examples above. Plot the following functions:
- Step function u[t] and u[n]
- Calculate a series of samples of a sine function of 50 Hz [for example 300 or more]. Plot these samples as dots into
a graph and plot the sine as well. Change the number of samples to a lower number. What can you deduce from the result?