Transformation of signals#

Time Reversal#

Mathematical Equation#

\[ y(t) = x(-t) \]

Explanation#

Time reversal flips the signal around the vertical axis. This means that the signal which occurs at \( t = a \) in the original signal will now occur at \( t = -a \).

import matplotlib.pyplot as plt
import numpy as np

# Define time variable
t = np.linspace(-2, 2, 400)
# Continuous signal (e.g., sine wave)
x = np.sin(2 * np.pi * t)
# Analog signal (e.g., square wave)
analog = np.sign(x)

# Time Reversal
y_time_reversal = x[::-1]
analog_time_reversal = analog[::-1]

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 6))

# Continuous signals
axs[0].plot(t, x, label='Original')
axs[0].plot(t, y_time_reversal, label='Time Reversal')
axs[0].set_title('Continuous Signals')
axs[0].legend()

# Analog signals
axs[1].plot(t, analog, label='Original', drawstyle='steps-pre')
axs[1].plot(t, analog_time_reversal, label='Time Reversal', drawstyle='steps-pre')
axs[1].set_title('Analog Signals')
axs[1].legend()

plt.show()
_images/2ee6dfbe9b9117fc086b53c2d97d342063357b994c29820c92d3428a12070ad0.png

Time Scaling#

Mathematical Equation#

\[ y(t) = x(at) \]

Explanation#

Time scaling compresses or expands the signal. If \( |a| > 1 \), the signal is compressed. If \( |a| < 1 \), the signal is expanded.

a = 0.5
y_time_scaling = np.sin(2 * np.pi * a * t)
analog_time_scaling = np.sign(np.sin(2 * np.pi * a * t))

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 6))

# Continuous signals
axs[0].plot(t, x, label='Original')
axs[0].plot(t, y_time_scaling, label='Time Scaling')
axs[0].set_title('Continuous Signals')
axs[0].legend()

# Analog signals
axs[1].plot(t, analog, label='Original', drawstyle='steps-pre')
axs[1].plot(t, analog_time_scaling, label='Time Scaling', drawstyle='steps-pre')
axs[1].set_title('Analog Signals')
axs[1].legend()

plt.show()
_images/cfbe6225260df8d6d91dc8ce7ea43cde3257d3103785b90ce555b4653b704095.png

Time Shifting#

Mathematical Equation#

\[ y(t) = x(t - t_0) \]

Explanation#

Time shifting moves the signal along the time axis. If \( t_0 > 0 \), the signal shifts to the right. If \( t_0 < 0 \), the signal shifts to the left.

t0 = 1.25
y_time_shifting = np.sin(2 * np.pi * (t - t0))
analog_time_shifting = np.sign(np.sin(2 * np.pi * (t - t0)))

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 6))

# Continuous signals
axs[0].plot(t, x, label='Original')
axs[0].plot(t, y_time_shifting, label='Time Shifting')
axs[0].set_title('Continuous Signals')
axs[0].legend()

# Analog signals
axs[1].plot(t, analog, label='Original', drawstyle='steps-pre')
axs[1].plot(t, analog_time_shifting, label='Time Shifting', drawstyle='steps-pre')
axs[1].set_title('Analog Signals')
axs[1].legend()

plt.show()
_images/94caf676b507be280bfd7493e0894d9ac72296d6edc887c438e04192e4debdb4.png

Amplitude Transformation#

Mathematical Equation#

\[ y(t) = a \cdot x(t) \]

Explanation#

Amplitude transformation changes the amplitude of the signal. If \( |a| > 1 \), the signal is amplified. If \( |a| < 1 \), the signal is attenuated.

amp_factor = 2
y_amp_transform = amp_factor * x
analog_amp_transform = amp_factor * analog

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 6))

# Continuous signals
axs[0].plot(t, x, label='Original')
axs[0].plot(t, y_amp_transform, label='Amplitude Transform')
axs[0].set_title('Continuous Signals')
axs[0].legend()

# Analog signals
axs[1].plot(t, analog, label='Original', drawstyle='steps-pre')
axs[1].plot(t, analog_amp_transform, label='Amplitude Transform', drawstyle='steps-pre')
axs[1].set_title('Analog Signals')
axs[1].legend()

plt.show()
_images/a2c1b4fca24bfe40a7a514f0b53711c037e0510f1160f3bb922bed70b20743d6.png

Additional Transformation: Time Dilation#

Mathematical Equation#

\[ y(t) = x(t / a) \]

Explanation#

Time dilation either stretches or compresses the time axis. If \( a > 1 \), the signal is stretched. If \( a < 1 \), the signal is compressed.

dilation_factor = 2
y_time_dilation = np.sin(2 * np.pi * (t / dilation_factor))
analog_time_dilation = np.sign(np.sin(2 * np.pi * (t / dilation_factor)))

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(12, 6))

# Continuous signals
axs[0].plot(t, x, label='Original')
axs[0].plot(t, y_time_dilation, label='Time Dilation')
axs[0].set_title('Continuous Signals')
axs[0].legend()

# Analog signals
axs[1].plot(t, analog, label='Original', drawstyle='steps-pre')
axs[1].plot(t, analog_time_dilation, label='Time Dilation', drawstyle='steps-pre')
axs[1].set_title('Analog Signals')
axs[1].legend()

plt.show()
_images/208b0d025e30698a06b33497d588f841c0bb5e5445f2ac082f52f72ee5edf5a4.png