Sub Plot all the Figures :

In [1]:
# Experiment No: 01
# Written by: Al Mamun Siddiki
In [2]:
import numpy as np
import matplotlib.pyplot as plt
In [3]:
n = range(-3, 4, 1)
y = []
for i in range(len(n)):
    temp = (1 if n[i] == 0 else 0)
    y.append(temp)
    
plt.subplot(221)
plt.stem(n, y)
plt.title('Unit Impulse')
plt.axis([-3.1, 3.1, -0.1, 1.1])
Out[3]:
[-3.1, 3.1, -0.1, 1.1]
In [4]:
n = range(-2, 6, 1)
y = []
for i in range(len(n)):
    temp = (1 if n[i]>=0 else 0)
    y.append(temp)
    
plt.subplot(222)
plt.stem(n, y)
plt.title('Unit Step')
plt.axis([-2.1, 5.1, -0.1, 1.2])
plt.grid(True)
In [5]:
n = range(-2, 6, 1)
y = []
for i in range(len(n)):
    temp = (n[i] if n[i]>=0 else 0)
    y.append(temp)
    
plt.subplot(223)
plt.stem(n, y)
plt.axis([-2.1, 5.1, -0.1, 5.2])
plt.title('Ramp Signal')
plt.grid(True)
In [6]:
a = 0.9
n = range(0, 26, 1)
y = []

for i in range(len(n)):
    temp = a**n[i]
    y.append(temp)
    
plt.subplot(224)
plt.stem(y)
plt.axis([-0.3, 25.1, -0.1, 1.1])
plt.title('Exponential signal')
plt.grid(True)
In [7]:
plt.show()
In [ ]: