text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

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

plt.figure(figsize=(12, 12))
plt.subplot(2, 2, 1)
plt.title('Analog Signal', fontsize=20)
plt.plot(t, x, linewidth=3, label='x(t) = (0.85)^t')
plt.xlabel('t', fontsize=15)
plt.ylabel('amplitude', fontsize=15)
plt.legend()
plt.subplot(2, 2, 2)
plt.title('Sampling', fontsize=20)
plt.plot(t, x, linewidth=3, label='x(t) = (0.85)^t')
n = t
markerline, stemlines, baseline = plt.stem(n, x, label='x(n) = (0.85)^n')
plt.setp(stemlines, 'linewidth', 3)
plt.xlabel('n', fontsize=15)
plt.ylabel('amplitude', fontsize=15)
plt.legend()
plt.subplot(2, 2, 3)
plt.title('Quantization', fontsize=20)
plt.plot(t, x, linewidth=3)
markerline, stemlines, baseline = plt.stem(n, x)
plt.setp(stemlines, 'linewidth', 3)
plt.xlabel('n', fontsize=15)
plt.ylabel('Range of Quantizer', fontsize=15)
plt.axhline(y=0.1, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.2, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.3, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.4, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.5, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.6, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.7, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.8, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.9, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=1.0, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.subplot(2, 2, 4)
plt.title('Quantized Signal', fontsize=20)
xq = np.around(x, 1)
markerline, stemlines, baseline = plt.stem(n, xq)
plt.setp(stemlines, 'linewidth', 3)
plt.xlabel('n', fontsize=15)
plt.ylabel('Range of Quantizer', fontsize=15)
plt.axhline(y=0.1, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.2, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.3, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.4, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.5, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.6, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.7, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.8, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=0.9, xmin=0, xmax=10, color='r', linewidth=3.0)
plt.axhline(y=1.0, xmin=0, xmax=10, color='r', linewidth=3.0)