This Jupyter notebook is part of a collection of notebooks in the bachelors module Signals and Systems, Comunications Engineering, Universität Rostock. Please direct questions and suggestions to Sascha.Spors@uni-rostock.de.
Operations like superposition, shifting and flipping can be used to construct signals with a more complex structure than by the standard signals alone. In the following, a set of elementary operations is introduced that are frequently used in discrete signal processing for this purpose. Note that the equivalent operation to the temporal scaling of a continuous signal is not defined for a discrete signal.
The weighted superposition $x[k]$ of two signals $x_1[k]$ and $x_2[k]$ is given as
\begin{equation} x[k] = A \cdot x_1[k] + B \cdot x_2[k] \end{equation}with the complex weights $A, B \in \mathbb{C}$.
Example
The following example illustrates the superposition of two harmonic signals $x(t) = A \cdot \cos[\Omega_1 k] + B \cdot \cos[\Omega_2 k]$ with weights $A$, $B$ and normalized frequencies $\Omega_1$ and $\Omega_2$.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
k = np.arange(0, 51)
x = np.cos(2 * np.pi / 10 * k) + 2 * np.cos(2 * np.pi / 15 * k)
plt.figure(figsize=(6, 3))
plt.stem(k, x)
plt.xlabel('$k$')
plt.ylabel('$x[k]$')
plt.gca().margins(y=0.1)
The shift of a signal $s[k]$ by the index $\kappa$ is defined as
\begin{equation} x[k] = s[k-\kappa] \end{equation}with $\kappa \in \mathbb{Z}$. The signal $s[k]$ is
The shift of a signal is a frequently applied operation in discrete signal processing. For instance for the description of systems by linear difference equations with constant coefficients. For a discrete signal which has been derived by temporal sampling from a continuous signal, the shift can be interpreted as temporal shift by the time $\tau = \kappa \cdot T$ where $T$ denotes the sampling interval.
Example
In order to illustrate the shifting of signals, the construction of a sawtooth signal by a superposition of shifted ramp signals $k \cdot \text{rect}_N[k]$ is shown. The sawtooth signal is given as periodic continuation of the ramp signal
\begin{equation} x[k] = \sum_{\nu = -\infty}^{\infty} (k - \nu \cdot N) \cdot \text{rect}_N[k - \nu \cdot N] \end{equation}The signal can be computed efficiently using the modulo operation
\begin{equation} x[k] = k \bmod N \end{equation}which is illustrated in the following
def sawtooth(k, N):
return np.mod(k, N)
k = np.arange(-10, 40)
x = sawtooth(k, 10)
plt.figure(figsize=(6, 3))
plt.stem(k, x)
plt.xlabel('$k$')
plt.ylabel('$x[k]$')
plt.gca().margins(y=0.1)
The flipping of a signal $s[k]$ is defined as
\begin{equation} x[k] = s[\kappa - k] \end{equation}with $\kappa \in \mathbb{Z}$. The flipping operation can also be represented as a reversal of the index $k$ of the signal $s[k]$ followed by a shift of $\kappa$ of the reversed signal, as $s[\kappa - k] = s[- (k - \kappa)]$. The operation can interpreted geometrically as a mirroring of the signal $s[k]$ at the vertical axis $k = \frac{\kappa}{2}$.
For $\kappa = 0$ this results in a reversal of the signal. The reversal can be interpreted as time-reversal for a discrete signal which has been derived by temporal sampling from a continuous signal.
Example
The following example illustrates the temporal flipping of the sawtooth signal $x[k]$ introduced above for $\kappa = 3$.
x = sawtooth(3 - k, 10)
plt.figure(figsize=(6, 3))
plt.stem(k, x)
plt.xlabel('$k$')
plt.ylabel('$x[k]$')
plt.gca().margins(y=0.1)
Excercise
Copyright
This notebook is provided as Open Educational Resource. Feel free to use the notebook for your own purposes. The text is licensed under Creative Commons Attribution 4.0, the code of the IPython examples under the MIT license. Please attribute the work as follows: Sascha Spors, Continuous- and Discrete-Time Signals and Systems - Theory and Computational Examples.