text_plain_output_1.png image_output_1.png
from scipy import signal

import matplotlib.pyplot as plt

import numpy as np

t = np.arange(0, 11)
x = 0.85 ** t

n = t
markerline, stemlines, baseline = plt.stem(n, x, label='x(n) = (0.85)^n')
plt.setp(stemlines, 'linewidth', 3)
markerline, stemlines, baseline = plt.stem(n, x)
plt.setp(stemlines, 'linewidth', 3)
xq = np.around(x, 1)
markerline, stemlines, baseline = plt.stem(n, xq)
plt.setp(stemlines, 'linewidth', 3)
plt.tight_layout()

impulse = signal.unit_impulse(10, 'mid')
shifted_impulse = signal.unit_impulse(7, 2)
t = np.linspace(0, 10, 100)
amp = 5
f = 50
x = amp * np.sin(2 * np.pi * f * t)
x_ = amp * np.exp(-t)

plt.figure(figsize=(10, 6))
plt.subplot(2, 2, 1)
plt.plot(np.arange(-5, 5), impulse, linewidth=3, label='Unit impulse function')
plt.ylim(-0.01, 1)
plt.xlabel('time.', fontsize=15)
plt.ylabel('Amplitude', fontsize=15)
plt.legend(fontsize=10, loc='upper right')
plt.subplot(2, 2, 2)
plt.plot(shifted_impulse, linewidth=3, label='Shifted Unit impulse function')
plt.xlabel('time.', fontsize=15)
plt.ylabel('Amplitude', fontsize=15)
plt.legend(fontsize=10, loc='upper right')
plt.subplot(2, 2, 3)
plt.plot(t, x, linewidth=3, label='Sine wave')
plt.xlabel('time.', fontsize=15)
plt.ylabel('Amplitude', fontsize=15)
plt.legend(fontsize=10, loc='upper right')
plt.subplot(2, 2, 4)
plt.plot(t, x_, linewidth=3, label='Exponential Signal')
plt.xlabel('time.', fontsize=15)
plt.ylabel('Amplitude', fontsize=15)
plt.legend(fontsize=10, loc='upper right')
plt.tight_layout()