Elementary operations on signals

Elementary operations on signals#

Here we will explore addition and scaling operations on signals.

Consider the following CT signal:

\(x(t)=\cos(t)\).

You can add a constant b to this signal. Let us see the effect of this operation by plotting the new signal:

\(y(t)=x(t)+b=\cos(t)+b\).

import sympy as sym

t = sym.symbols('t', real=True)

# scalar constant
b = 1

# the signals:
x = sym.cos(t)
y = sym.cos(t)+b

p1 = sym.plot(x, (t, 0, 2*sym.pi), legend=True, label='cos(t)', show=False);
p2 = sym.plot(y, (t, 0, 2*sym.pi), legend=True, label='cos(t)+b', show=False);

p1.append(p2[0])
p1.show()
_images/8c4a5ad1fce865feb58b4be6f374d43eecd82f17c63a26d17fbfdb1368d1ee32.png

Change the value of constant b above to see its effect.

When you multiply a signal with a scalar number, the value of the signal scales accordingly. Observe the plots of \(x(t)\) and \(y(t)\) below.

# scalar constant
a = 0.5

# the signal:
x = sym.cos(t)
y = a*sym.cos(t)

p1 = sym.plot(x, (t, 0, 2*sym.pi), legend=True, label='cos(t)', show=False);
p2 = sym.plot(y, (t, 0, 2*sym.pi), legend=True, label='a cos(t)', show=False);

p1.append(p2[0])
p1.show()
_images/e79c3662d37f18e92bf8f0e1211b302d601df85d43e7573858ffe12c2bccd64e.png

You can combine both operations to obtain:

\(y(t) = a x(t) + b\).

Change the values of a and b below to see their effects.

# scalar constant
a = 0.5
b = -0.5

# the signal:
x = sym.cos(t)
y = a*sym.cos(t)+b

p1 = sym.plot(x, (t, 0, 2*sym.pi), legend=True, label='cos(t)', show=False);
p2 = sym.plot(y, (t, 0, 2*sym.pi), legend=True, label='a cos(t)+b', show=False);

p1.append(p2[0])
p1.show()
_images/20b86da52f240d4d817a39c116e33daf833d87bbf783e8dafb0f71fb8ce2957e.png

We can also add two or more signals together to obtain a more complicated signal.

Let us now create two signals, \(x\) and \(y\), and add them to obtain a third signal, \(z\). Let

\(x(t) = \cos(t) -\frac{1}{2}\),

\(y(t) = \frac{1}{5} t \), and

\(z(t) = x(t) + y(t)\).

The following code creates \(z(t)\) and plots it.

x = sym.cos(t)-0.5
y = 0.2*t
z = x + y

sym.plot(z);
_images/3f52bd66c3337efa52c29b9d023a2bdd076fad40fe5277f937676fe623c4cf0a.png

Exercise: Play with the coefficients of \(x\), \(y\), and \(t\) above. Observe how the shape of \(z(t)\) changes.


Related content:

Explore different types of signals.

Explore operations on the time variable of signals.

Decompose signals into their even and odd parts.